--- a/Makefile Sat Feb 12 15:26:27 2011 +0300
+++ b/Makefile Sat Feb 12 17:03:08 2011 +0300
@@ -20,8 +20,13 @@
cos-dbupdate: cos-dbupdate.cxx
@echo C++ $<
- @${CXX} -O0 -g cos-dbupdate.cxx -o cos-dbupdate ${CFLAGS} ${LDFLAGS}
+ @${CXX} -O0 -g $< -o $@ ${CFLAGS} ${LDFLAGS}
cos-search: cos-search.cxx
@echo C++ $<
- @${CXX} -O0 -g cos-search.cxx -o cos-search ${CFLAGS} ${LDFLAGS}
\ No newline at end of file
+ @${CXX} -O0 -g cos-search.cxx -o cos-search ${CFLAGS} ${LDFLAGS}
+
+cos-list: cos-list.cxx
+ @echo C++ $<
+ @${CXX} -O0 -g $< -o $@ ${CFLAGS} ${LDFLAGS}
+
\ No newline at end of file
--- a/cos-dbupdate.cxx Sat Feb 12 15:26:27 2011 +0300
+++ b/cos-dbupdate.cxx Sat Feb 12 17:03:08 2011 +0300
@@ -49,17 +49,22 @@
break;
Xapian::Document newdocument;
newdocument.set_data(fname);
- newdocument.add_posting("FILENAME:"+fname, 0);
+ string fnameterm = "FILENAME:"+fname;
+ if (fnameterm.length()>245)
+ fnameterm.erase(245);
+ newdocument.add_posting(fnameterm, 0);
int i=1;
while (1) {
string term;
getline(cin,term);
if (cin.eof()||term.empty())
break;
+ if (term.length()>245)
+ term.erase(245);
cout << "TERM <" << term << ">" << endl;
newdocument.add_posting(term, i++);
}
- database.replace_document("FILENAME:"+fname,newdocument);
+ database.replace_document(fnameterm,newdocument);
cout << "EOFILE <" << fname << ">" << endl;
}
} catch(const Xapian::Error &error) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extractors/Makefile Sat Feb 12 17:03:08 2011 +0300
@@ -0,0 +1,14 @@
+
+include ../config.mk
+
+OBJS = ext-taglib
+
+all: ${OBJS}
+
+clean:
+ rm -f ${OBJS}
+
+ext-taglib: extractor-taglib.cxx
+ @echo C++ $<
+ @${CXX} -O0 -g $< -o $@ ${CFLAGS} ${LDFLAGS} `taglib-config --libs --cflags`
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extractors/ext-mpg123 Sat Feb 12 17:03:08 2011 +0300
@@ -0,0 +1,6 @@
+#!/bin/sh
+echo "$1"
+mpg123 -vtn1 --long-tag "$1" 2>&1|awk '/^\t.*:/ {match($0,"\t(.*): +(.*)",a); print toupper(a[1])":"a[2]; }'
+echo
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extractors/extractor-taglib.cxx Sat Feb 12 17:03:08 2011 +0300
@@ -0,0 +1,76 @@
+/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <iostream>
+#include <stdio.h>
+
+#include <fileref.h>
+#include <tag.h>
+
+using namespace std;
+
+TagLib::String formatSeconds(int seconds)
+{
+ char secondsString[3];
+ sprintf(secondsString, "%02i", seconds);
+ return secondsString;
+}
+
+int main(int argc, char *argv[])
+{
+ for(int i = 1; i < argc; i++) {
+
+ cout << argv[i] << endl;
+
+ TagLib::FileRef f(argv[i]);
+
+ if(!f.isNull() && f.tag()) {
+
+ TagLib::Tag *tag = f.tag();
+
+ cout << "TITLE:" << tag->title() << endl;
+ cout << "ARTIST:" << tag->artist() << endl;
+ cout << "ALBUM:" << tag->album() << endl;
+ cout << "YEAR:" << tag->year() << endl;
+ cout << "COMMENT:" << tag->comment() << endl;
+ cout << "TRACK:" << tag->track() << endl;
+ cout << "GENRE:" << tag->genre() << endl;
+ }
+
+ if(!f.isNull() && f.audioProperties()) {
+
+ TagLib::AudioProperties *properties = f.audioProperties();
+
+ int seconds = properties->length() % 60;
+ int minutes = (properties->length() - seconds) / 60;
+
+ cout << "BITRATE:" << properties->bitrate() << endl;
+ cout << "SAMPLERATE:" << properties->sampleRate() << endl;
+ cout << "CHANNELS:" << properties->channels() << endl;
+ cout << "LENGTH:" << minutes << ":" << formatSeconds(seconds) << endl;
+ }
+ cout << endl;
+ }
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/myup.sh Sat Feb 12 17:03:08 2011 +0300
@@ -0,0 +1,6 @@
+#!/bin/bash
+PROGDIR=$(dirname $(readlink -f $0))
+cd "$PROGDIR"
+for x in /home/media/music /home/common/music /home/stil/r/anubis/common/music /home/stil/r/anubis/common/cls/Boa_n_SEL; do
+ ./scanscript.sh "$x" | ./cos-dbupdate fuck
+done
--- a/scanscript.sh Sat Feb 12 15:26:27 2011 +0300
+++ b/scanscript.sh Sat Feb 12 17:03:08 2011 +0300
@@ -1,5 +1,10 @@
#!/bin/sh
PROGDIR=$(dirname $(readlink -f $0))
find "$1" -type f| while read fname; do
- $PROGDIR/extractors/ext-taglib "$fname"
+ EXT="${fname/*./}"
+ if [ "$EXT" == "mp3" ];then
+ $PROGDIR/extractors/ext-mpg123 "$fname"
+ else
+ true#$PROGDIR/extractors/ext-taglib "$fname"
+ fi
done