diff options
author | wr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-03-01 09:14:34 +0000 |
---|---|---|
committer | wr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-03-01 09:14:34 +0000 |
commit | da32226853182c5fb1ef101a478e3b7c8bec7f76 (patch) | |
tree | 1741670cce61e8a48a0613f5c458bc6a41db4e08 | |
parent | 4e4788985445d9943d2965884f5f092c687d05f5 (diff) | |
download | vdr-plugin-muggle-da32226853182c5fb1ef101a478e3b7c8bec7f76.tar.gz vdr-plugin-muggle-da32226853182c5fb1ef101a478e3b7c8bec7f76.tar.bz2 |
rename mg_actions to vdr_actions, *.h no longer include i18n.h, Sync: intelligent album handling, remove option -a (assorted)
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/branches/0.1.3-wr@520 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | mg_content.c | 1 | ||||
-rw-r--r-- | mg_content.h | 1 | ||||
-rw-r--r-- | mg_selection.c | 63 | ||||
-rw-r--r-- | mg_selection.h | 3 | ||||
-rw-r--r-- | vdr_actions.c (renamed from mg_actions.c) | 6 | ||||
-rw-r--r-- | vdr_actions.h (renamed from mg_actions.h) | 9 | ||||
-rw-r--r-- | vdr_menu.h | 3 |
8 files changed, 62 insertions, 26 deletions
@@ -55,7 +55,7 @@ MIFLAGS += -I/usr/include/taglib -lmysqlclient ### The object files (add further files here): -OBJS = $(PLUGIN).o i18n.o mg_valmap.o mg_mysql.o mg_order.o mg_content.o mg_selection.o mg_actions.o vdr_menu.o mg_tools.o \ +OBJS = $(PLUGIN).o i18n.o mg_valmap.o mg_mysql.o mg_order.o mg_content.o mg_selection.o vdr_actions.o vdr_menu.o mg_tools.o \ vdr_decoder_mp3.o vdr_stream.o vdr_decoder.o vdr_player.o \ vdr_setup.o mg_setup.o diff --git a/mg_content.c b/mg_content.c index 8e2ca29..5e8ecf6 100644 --- a/mg_content.c +++ b/mg_content.c @@ -10,6 +10,7 @@ */ #include <stdio.h> +#include "i18n.h" #include "mg_selection.h" #include "vdr_setup.h" #include "mg_tools.h" diff --git a/mg_content.h b/mg_content.h index 76d5869..313b54b 100644 --- a/mg_content.h +++ b/mg_content.h @@ -17,7 +17,6 @@ #include <list> #include <vector> #include <map> -#include <i18n.h> using namespace std; #include "mg_tools.h" diff --git a/mg_selection.c b/mg_selection.c index f01063a..76abf5c 100644 --- a/mg_selection.c +++ b/mg_selection.c @@ -15,6 +15,7 @@ #include <stdio.h> #include <fts.h> +#include "i18n.h" #include "mg_selection.h" #include "vdr_setup.h" #include "mg_tools.h" @@ -1181,24 +1182,56 @@ mgSelection::getlanguage(const char *filename) } char * -mgSelection::getAlbum(const char *c_album,const char *c_artist,const char *c_title) +mgSelection::getAlbum(const char *c_album,const char *c_artist,const char *c_directory) { char * result; char *b; asprintf(&b,"SELECT cddbid FROM album" - " WHERE title=%s AND artist=%s",c_title,c_artist); + " WHERE title=%s AND artist=%s",c_album,c_artist); result=m_db.sql_Cstring(m_db.get_col0(b)); free(b); if (!strcmp(result,"'NULL'")) { - asprintf(&result,"'%ld-%9s",random(),c_artist+1); - char *p=strchr(result,0)-1; - if (*p!='\'') - *p='\''; - asprintf(&b,"INSERT INTO album SET artist=%s,title=%s,cddbid=%s", - c_artist,c_album,result); - m_db.exec_sql(b); + const char *directory="substring(tracks.mp3file,1,length(tracks.mp3file)" + "-instr(reverse(tracks.mp3file),'/'))"; + char *where; + asprintf(&where,"WHERE tracks.sourceid=album.cddbid " + "AND %s=%s " + "AND album.title=%s", + directory,c_directory, + c_album); + + // how many artists will the album have after adding this one? + asprintf(&b,"SELECT distinct album.artist FROM tracks, album %s " + " union select %s",where,c_artist); + //MYSQL_RES *rows = m_db.exec_sql (b); + m_db.exec_sql (b); free(b); + long new_album_artists = m_db.affected_rows(); + if (new_album_artists>1) // is the album multi artist? + { + asprintf(&b,"SELECT album.cddbid FROM tracks, album %s",where); + result=m_db.sql_Cstring(m_db.get_col0(b)); + free(b); + asprintf(&b,"UPDATE album SET artist='Various Artists' WHERE cddbid=%s",result); + m_db.exec_sql(b); + // here we could change all tracks.sourceid to result and delete + // the other album entries for this album, but that should only + // be needed if a pre 0.1.4 import has been done incorrectly, so we + // don't bother + } + else + { // no usable album found + asprintf(&result,"'%ld-%9s",random(),c_artist+1); + char *p=strchr(result,0)-1; + if (*p!='\'') + *p='\''; + asprintf(&b,"INSERT INTO album SET title=%s,artist=%s,cddbid=%s", + c_album,c_artist,result); + m_db.exec_sql(b); + free(b); + } + free(where); } return result; } @@ -1206,8 +1239,6 @@ mgSelection::getAlbum(const char *c_album,const char *c_artist,const char *c_tit void mgSelection::AddTrack(const char *filename) { -// mgDebug(1,"%s:AddTrack(%s)",get_current_dir_name(),filename); - TagLib::FileRef f( filename) ; if (f.isNull()) return; @@ -1221,7 +1252,14 @@ mgSelection::AddTrack(const char *filename) c_album=sql_Cstring(tag->album()); char *c_artist=sql_Cstring(tag->artist()); char *c_title=sql_Cstring(tag->title()); - char *c_cddbid=getAlbum(c_album,c_artist,c_title); + char *c_directory=sql_Cstring(filename); + char *slash=strrchr(c_directory,'/'); + if (slash) + { + *slash='\''; + *(slash+1)=0; + } + char *c_cddbid=getAlbum(c_album,c_artist,c_directory); char *c_mp3file=sql_Cstring(filename); char *c_genre1=sql_Cstring(id(keyGenres,tag->genre().to8Bit())); char *c_lang=sql_Cstring(getlanguage(filename)); @@ -1289,6 +1327,7 @@ mgSelection::AddTrack(const char *filename) c_artist,c_title,year,c_cddbid, trackno,c_mp3file,len,bitrate,sample, channels,c_genre1,c_lang,folderstring); + free(c_directory); free(c_album); free(c_artist); free(c_title); diff --git a/mg_selection.h b/mg_selection.h index 4a8f298..b8acc26 100644 --- a/mg_selection.h +++ b/mg_selection.h @@ -16,7 +16,6 @@ #include <list> #include <vector> #include <map> -#include <i18n.h> using namespace std; #include "mg_tools.h" @@ -471,7 +470,7 @@ class mgSelection char *sql_Cstring(TagLib::String s); char *lower(char *s); TagLib::String getlanguage(const char *filename); - char * getAlbum(const char *c_album,const char *c_artist,const char *c_title); + char * getAlbum(const char *c_album,const char *c_artist,const char *c_directory); void AddTrack(const char *filename); void SyncFile(const char *filename); diff --git a/mg_actions.c b/vdr_actions.c index 2934ee4..5ba6275 100644 --- a/mg_actions.c +++ b/vdr_actions.c @@ -1,12 +1,12 @@ /*! - * \file mg_actions.c + * \file vdr_actions.c * \brief Implements all actions for browsing media libraries within VDR * * \version $Revision: 1.27 $ * \date $Date: 2004-12-25 16:52:35 +0100 (Sat, 25 Dec 2004) $ * \author Wolfgang Rohdewald * \author Responsible author: $Author: wr61 $ * - * $Id: mg_actions.c 276 2004-12-25 15:52:35Z wr61 $ + * $Id: vdr_actions.c 276 2004-12-25 15:52:35Z wr61 $ */ #include <stdio.h> @@ -21,7 +21,7 @@ #include <plugin.h> #include "vdr_setup.h" -#include "mg_actions.h" +#include "vdr_actions.h" #include "vdr_menu.h" #include "i18n.h" #include <vdr/interface.h> diff --git a/mg_actions.h b/vdr_actions.h index ac12586..29713f1 100644 --- a/mg_actions.h +++ b/vdr_actions.h @@ -1,5 +1,5 @@ /*! - * \file mg_actions.h + * \file vdr_actions.h * \brief Implements all actions for broswing media libraries within VDR * * \version $Revision: 1.13 $ @@ -7,17 +7,16 @@ * \author Wolfgang Rohdewald * \author Responsible author: $Author: wr61 $ * - * $Id: mg_actions.h 276 2004-12-25 15:52:35Z wr61 $ + * $Id: vdr_actions.h 276 2004-12-25 15:52:35Z wr61 $ */ -#ifndef _MG_ACTIONS_H -#define _MG_ACTIONS_H +#ifndef _VDR_ACTIONS_H +#define _VDR_ACTIONS_H #include <string> #include <osd.h> #include <plugin.h> -#include "i18n.h" using namespace std; @@ -20,8 +20,7 @@ #include <osd.h> #include <plugin.h> #include <status.h> -#include "i18n.h" -#include "mg_actions.h" +#include "vdr_actions.h" #include "vdr_player.h" |