From: kaliko Date: Wed, 28 Jan 2015 18:21:42 +0000 (+0100) Subject: Huge clean-up X-Git-Tag: 0.14.0~33 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=d906b7f06726d9dd34ac9a6873bdf8fe683059d4;p=mpd-sima.git Huge clean-up --- diff --git a/data/man/info.xml b/data/man/info.xml index 50abd24..046a8a7 100644 --- a/data/man/info.xml +++ b/data/man/info.xml @@ -5,7 +5,7 @@ - + @@ -30,6 +30,7 @@ 2012 2013 2014 + 2015 &dhusername; diff --git a/data/man/mpd-sima.1 b/data/man/mpd-sima.1 index 6bd8ac2..3739b64 100644 --- a/data/man/mpd-sima.1 +++ b/data/man/mpd-sima.1 @@ -2,12 +2,12 @@ .\" Title: mpd-sima .\" Author: Jack Kaliko .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/08/2014 -.\" Manual: mpd-sima 0.13.0 User Manual +.\" Date: 01/28/2015 +.\" Manual: mpd-sima 0.13.1 User Manual .\" Source: mpd-sima .\" Language: English .\" -.TH "MPD\-SIMA" "1" "12/08/2014" "mpd-sima" "mpd-sima 0.13.0 User Manual" +.TH "MPD\-SIMA" "1" "01/28/2015" "mpd-sima" "mpd-sima 0.13.1 User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,7 +33,7 @@ mpd-sima \- mpd\-sima will try to maintain some titles ahead in the queue follow .HP \w'\fBmpd\-sima\fR\ 'u \fBmpd\-sima\fR [\fB\-\-daemon\fR] [\fB\-\-config=\fR\fIconf_file\fR] [\fB\-\-var_dir=\fR\fIvar_directory\fR] [\fB\-\-pid=\fR\fIpid_file\fR] [\fB\-\-log=\fR\fIlog_file\fR] [\fB\-\-log\-level=\fR\fIlog_level\fR] [\fB\-\-host=\fR\fImpd_host\fR] [\fB\-\-mpd_port=\fR\fImpd_port\fR] .HP \w'\fBmpd\-sima\fR\ 'u -\fBmpd\-sima\fR [\fB\-\-var_dir=\fR\fIvar_directory\fR] [\fB\-\-create\-db>\fR] +\fBmpd\-sima\fR [\fB\-\-var_dir=\fR\fIvar_directory\fR] [\fB\-\-create\-db\fR] .HP \w'\fBmpd\-sima\fR\ 'u \fBmpd\-sima\fR [{\fB\-h\fR\ |\ \fB\-\-help\fR} | \fB\-\-version\fR] .SH "DESCRIPTION" @@ -258,7 +258,7 @@ DEFAULTS .RS 4 Default is to look for MPD server at localhost:6600 (or MPD_HOST/MPD_PORT env\&. var\&. if set)\&. .sp -The default behavior is to add one track, this track is to be chosen among titles from artists similar to the artist of the currently played track\&. MPD_sima will add one track when the unplayed queue is one track long\&. +The default behavior is to add one track, this track is to be chosen among titles from artists similar to the last artist in the queue\&. MPD_sima will add one track when the unplayed queue is one track long\&. .sp To change these defaults, use the configuration file mpd_sima\&.cfg @@ -288,7 +288,7 @@ Wrote this man page and is currently leading MPD_sima project\&. .RE .SH "COPYRIGHT" .br -Copyright \(co 2009-2014 Jack Kaliko +Copyright \(co 2009-2015 Jack Kaliko .br .PP This manual page was written for the Debian system (and may be used by others)\&. diff --git a/data/man/mpd_sima.1.xml b/data/man/mpd_sima.1.xml index f187b5e..48cf028 100644 --- a/data/man/mpd_sima.1.xml +++ b/data/man/mpd_sima.1.xml @@ -74,7 +74,7 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ &dhpackage; var_directory - + &dhpackage; @@ -250,11 +250,11 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ DEFAULTS Default is to look for MPD server at localhost:6600 (or MPD_HOST/MPD_PORT env. var. if set). - The default behavior is to add one track, - this track is to be chosen among titles from - artists similar to the artist of the currently - played track. MPD_sima will add one track when the - unplayed queue is one track long. + The default behavior is to add one track, this + track is to be chosen among titles from artists + similar to the last artist in the queue. MPD_sima + will add one track when the unplayed queue is one + track long. To change these defaults, use the configuration file mpd_sima.cfg diff --git a/data/man/mpd_sima.cfg.5 b/data/man/mpd_sima.cfg.5 index 46c73f0..aad901f 100644 --- a/data/man/mpd_sima.cfg.5 +++ b/data/man/mpd_sima.cfg.5 @@ -2,12 +2,12 @@ .\" Title: mpd_sima.cfg .\" Author: Jack Kaliko .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/09/2014 -.\" Manual: mpd-sima 0.13.0 User Manual +.\" Date: 01/28/2015 +.\" Manual: mpd-sima 0.13.1 User Manual .\" Source: mpd-sima .\" Language: English .\" -.TH "MPD_SIMA\&.CFG" "5" "12/09/2014" "mpd-sima" "mpd-sima 0.13.0 User Manual" +.TH "MPD_SIMA\&.CFG" "5" "01/28/2015" "mpd-sima" "mpd-sima 0.13.1 User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -174,11 +174,6 @@ Use Picard to tag your file: \m[blue]\fB\%https://picard.musicbrainz.org/\fR\m[]\&. .RE .PP -\fBuser_db=\fR\fIfalse\fR -.RS 4 -Temporarily removed feature -.RE -.PP mpd\-sima\*(Aqs plugin management for internal source plugin and contrib (ie\&. external plugins)\&. .br @@ -430,7 +425,7 @@ Wrote this man page and is currently leading MPD_sima project\&. .RE .SH "COPYRIGHT" .br -Copyright \(co 2009-2014 Jack Kaliko +Copyright \(co 2009-2015 Jack Kaliko .br .PP This manual page was written for the Debian system (and may be used by others)\&. diff --git a/data/man/mpd_sima.cfg.5.xml b/data/man/mpd_sima.cfg.5.xml index 309beff..ef483a1 100644 --- a/data/man/mpd_sima.cfg.5.xml +++ b/data/man/mpd_sima.cfg.5.xml @@ -214,13 +214,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ - - false - - Temporarily removed feature - - - &dhpackage;'s plugin management for internal source plugin and contrib (ie. external plugins). Plugins list is a diff --git a/data/man/simadb_cli.1 b/data/man/simadb_cli.1 index f39167e..c2c5172 100644 --- a/data/man/simadb_cli.1 +++ b/data/man/simadb_cli.1 @@ -2,12 +2,12 @@ .\" Title: simadb_cli .\" Author: Jack Kaliko .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/08/2014 -.\" Manual: mpd-sima 0.13.0 User Manual +.\" Date: 01/28/2015 +.\" Manual: mpd-sima 0.13.1 User Manual .\" Source: mpd-sima .\" Language: English .\" -.TH "SIMADB_CLI" "1" "12/08/2014" "mpd-sima" "mpd-sima 0.13.0 User Manual" +.TH "SIMADB_CLI" "1" "01/28/2015" "mpd-sima" "mpd-sima 0.13.1 User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,16 +31,10 @@ simadb_cli \- simadb_cli is a command line interface editor for the sima user DB\&. .SH "SYNOPSIS" .HP \w'\fBsimadb_cli\fR\ 'u -\fBsimadb_cli\fR \fB\-\-add_similarity=\fR\fIsimilarity_string\fR [\fB\-\-check_names\fR] [\fB\-\-dbfile=\fR\fIdb_file\fR] [\fB\-\-reciprocal\fR] [\fB\-\-host=\fR\fImpd_host\fR] [\fB\-\-port=\fR\fImpd_port\fR] -.HP \w'\fBsimadb_cli\fR\ 'u \fBsimadb_cli\fR \fB\-\-remove_artist=\fR\fIartist\fR [\fB\-\-dbfile=\fR\fIdb_file\fR] [\fB\-\-reciprocal\fR] .HP \w'\fBsimadb_cli\fR\ 'u -\fBsimadb_cli\fR \fB\-\-remove_similarity=\fR\fI"main\ artist,similar\ artist"\fR [\fB\-\-dbfile=\fR\fIdb_file\fR] [\fB\-\-reciprocal\fR] -.HP \w'\fBsimadb_cli\fR\ 'u \fBsimadb_cli\fR \fB\-\-purge_hist\fR [\fB\-\-dbfile=\fR\fIdb_file\fR] .HP \w'\fBsimadb_cli\fR\ 'u -\fBsimadb_cli\fR \fB\-\-view_artist=\fR\fB\fI"artist\ name"\fR\fR [\fB\-\-dbfile=\fR\fIdb_file\fR] -.HP \w'\fBsimadb_cli\fR\ 'u \fBsimadb_cli\fR \fB\-\-view_all\fR [\fB\-\-dbfile=\fR\fIdb_file\fR] .HP \w'\fBsimadb_cli\fR\ 'u \fBsimadb_cli\fR {\fB\-\-bl_curr_trk\fR | \fB\-\-bl_curr_art\fR | \fB\-\-bl_curr_alb\fR | \fB\-\-bl_art=\fR\fIartist_name\fR} [\fB\-\-dbfile=\fR\fIdb_file\fR] [\fB\-\-host=\fR\fImpd_host\fR] [\fB\-\-port=\fR\fImpd_port\fR] @@ -56,37 +50,9 @@ This manual page documents briefly the \fBsimadb_cli\fR commands\&. .PP -simadb_cli is a command line interface to get and edit users similarities and blacklist database used with MPD_sima\&. The default database file (see +simadb_cli is a command line interface to get and edit users blacklist database used with MPD_sima\&. The default database file (see the section called \(lqFILES\(rq) can be overridden if you want\&. -.PP -Consider reading -the section called \(lqA WORD ABOUT SIMA DATA BASE\(rq -to understand the structure and relation of similarities within the database\&. .SH "EXAMPLE" -.SS "Similarity edition" -.PP -Here follows some simple examples on how to deal with similarity database\&. -.PP -Pay attention, the following examples set one\-way similarities in the DB! Read more about it in -the section called \(lqA WORD ABOUT SIMA DATA BASE\(rq\&. -.PP -\fIAdding a similarity between two artists\&.\fR -In the following example "Pelican" will point to "Russian Circles" with a match score of 88% (ie\&. "Russian Circles" 88% similar to Pelican, not reciprocal), it will also check against MPD the presence of both artists in the music library\&. -.PP -\fBsimadb_cli \-\-add "Pelican,Russian Circles:80" \-\-check_names\fR -.PP -Similarity string use comma "," as artists separator and semi colon ":" for artist/similarity score separator, cf\&. -the section called \(lqSIMILARITY FORMAT\(rq\&. -.PP -\fIAdding a similarity between multiple artists\&.\fR -In the following example "Rage Against The Machine" will point to "Tool" and "Audioslave" as similar artists and controls artists names are actually in MPD music library\&. -.PP -\fBsimadb_cli \-\-add "Rage Against The Machine,Tool:70,Audiosalve:80" \-\-check_names\fR -.PP -\fIViewing similarit(y|ies) for an artist\&.\fR -In the following example we are looking for entries for "Rage Against The Machine" -.PP -\fBsimadb_cli \-\-view_artist "Rage Against The Machine"\fR .SS "Black list edition" .PP \fIAdding to black list\&.\fR @@ -119,33 +85,6 @@ Print help and exit\&. Print version and exit\&. .RE .PP -\fB\-a \fR\fB\fIsimilarity_string\fR\fR, \fB\-\-add_similarity=\fR\fB\fIsimilarity_string\fR\fR -.RS 4 -Add similarity to the database\&. -.br -For more details about the -\fIsimilarity_string\fR -see -the section called \(lqSIMILARITY FORMAT\(rq\&. -.RE -.PP -\fB\-c\fR, \fB\-\-check_names\fR -.RS 4 -Use with -\fB\-\-add_similarity\fR -in order to check artists names used in -\fIsimilarity_string\fR\&. simadb_cli will control presence of artists names in MPD library\&. Default is to look for MPD server on localhost:6600 or environment variables -\fBMPD_HOST\fR -and -\fBMPD_PORT\fR -if set\&. -.br -You can as well give simadb_cli host/port on the command line using respectively -\fB\-S\fR -and -\fB\-P\fR\&. -.RE -.PP \fB\-\-bl_art=\fR\fB\fIartist_name\fR\fR .RS 4 Use to black list @@ -188,28 +127,6 @@ the section called \(lqFILES\(rq)\&. Purge history, you may supply an alternative DB file with \-\-dbfile option\&. .RE .PP -\fB\-r\fR, \fB\-\-reciprocal\fR -.RS 4 -Use with an editing options in order to edit reciprocal similarity as well\&. -\fB\-\-add_similarity\fR -and -\fB\-\-remove_{artist|similarity}\fR -are supporting reciprocal edition\&. -.sp -\fIN\&.B\fR: this option has to appear after the editing option on the command line\&. -.sp -See -the section called \(lqA WORD ABOUT SIMA DATA BASE\(rq -for further information about reciprocity notion\&. -.RE -.PP -\fB\-\-remove_artist=\fR\fB\fIartist\fR\fR -.RS 4 -Use to remove an artist entry (as main artist) with its associated similarities\&. To remove artist where it appears as a similar artist use the -\fB\-\-reciprocal\fR -option\&. -.RE -.PP \fB\-\-remove_bl=\fR\fB\fIrow_id\fR\fR .RS 4 Use to remove a black list entry\&. To get the row_id to suppress use @@ -217,37 +134,11 @@ Use to remove a black list entry\&. To get the row_id to suppress use option\&. .RE .PP -\fB\-\-remove_similarity=\fR\fB\fI"main artist,similar artist"\fR\fR -.RS 4 -Use to remove a single similarity between a main artist and an associated similarity\&. Give the main artist first, use comma (",") to separate it from similar artist\&. -.br -Use of -\fB\-\-reciprocal\fR -is possible here, see -the section called \(lqA WORD ABOUT SIMA DATA BASE\(rq\&. -.sp -This option is useful in case you want to remove only a specific similarity between two artists, to remove completely an artist use -\fB\-\-remove_artist\fR -instead\&. -.RE -.PP -\fB\-v \fR\fB\fI"artist name"\fR\fR, \fB\-\-view_artist=\fR\fB\fI"artist name"\fR\fR -.RS 4 -Get entries for -\fI"artist name"\fR -in the data base (print to stdout)\&. -.RE -.PP \fB\-\-view_bl\fR .RS 4 Get all entries in the black list\&. .RE .PP -\fB\-\-view_all\fR -.RS 4 -Get all entries in the data base (print to stdout)\&. -.RE -.PP \fB\-P \fR\fB\fImpd_port\fR\fR, \fB\-\-port=\fR\fB\fImpd_port\fR\fR .RS 4 Use the specific port number @@ -285,70 +176,6 @@ SQLite DB file\&. Usually is set to ${HOME}/\&.local/share\&. .RE -.SH "SIMILARITY FORMAT" -.PP -The -\fIsimilarity_string\fR -has to be formatted following a special pattern in order for simadb_cli to extract similarity relations between artists names\&. Usually a similarity entry is defined as a main artist, lets say -\fImain_art\fR, followed by a list of similar artists which you want to be related to that -\fImain_art\fR, each artist of that list with a specific similarity value, a match score, quantifying the similarity relation with the -\fImain_art\fR\&. The match score value is an integer in [0 ,100] with 100 corresponding to a perfect match\&. -.PP -\fIsimilarity_string\fR -is then to be formatted as follow: -.PP -\fBmain_art,first artist:,second artist:\fR -.PP -Each artist group are separated with commas (",") and inside each group the artist name and the match score is colon (":") separated\&. Obviously the first artist group, as the main artist, does not have a match score\&. -.PP -Lets see how it works with an example\&. I consider "Led Zeppelin" to be similar to "Tool" with a match score of 25, I also want to have "Audioslave" related to "Led Zeppelin" with a score of 20\&. Then the -\fIsimilarity_string\fR -will be the following: -.PP -\fBLed Zeppelin,Tool:25,Audiosalve:20\fR -.PP -See -the section called \(lqA WORD ABOUT SIMA DATA BASE\(rq -for more details about how similarities are handled -.SH "A WORD ABOUT SIMA DATA BASE" -.PP -The similarity database is defined from the point of view of a -\fImain artist\fR -which is declared related to a list of -\fIsimilar artists\fR\&. That means when you define -\fImain_art\fR -to be similar to -\fIsim_art A\fR -and -\fIsim_art B\fR -the reciprocal won\*(Aqt be true, -\fIsim_art A\fR -and -\fIsim_art B\fR -are not similar to -\fImain_art\fR\&. At least this is the default behavior when you edit entries with simadb_cli, this is also the way last\&.fm is working concerning similar artists\&. This documentation is using that particular terminology to specify which kind of artist we are dealing with : "main artist" or "similar artist"\&. -.br -The -\fB\-\-reciprocal\fR -option allows one to add reciprocal relation where -\fIsim_art A\fR -and -\fIsim_art B\fR -become respectively the -\fImain_art\fR\&. Using -\fB\-\-reciprocal\fR -you will then edit two more entries in the database\&. To summarize here is what you\*(Aqll end up with in your data base adding similarity with this string -\fBmain_art,sim_art A:34,sim_art B:45\fR\&. -.PP -\fBsimadb_cli \-\-reciprocal \-\-add_similarity=main_art,sim_art A:34,sim_art B:45\fR -.PP -main_art similar to sim_art A:34 and sim_art B:45 -.br -sim_art A similar to main_art:34 -.br -sim_art B similar to main_art:45 -.PP -Without the reciprocal option you would have add only the first similarity\&. Usually using the reciprocal option is the desired behavior, at least what users have in mind when thinking of similarity relation between to artists but keep in mind that it may lead to have MPD_sima more sensible to loop over the same two artist (ASSERTION TO BE CONFIRMED)\&. .SH "FEEDBACK/BUGS" .PP The maintainer would be more than happy to ear from you, don\*(Aqt hesitate to send feedback, @@ -371,7 +198,7 @@ Wrote this man page and is currently leading MPD_sima project\&. .RE .SH "COPYRIGHT" .br -Copyright \(co 2009-2014 Jack Kaliko +Copyright \(co 2009-2015 Jack Kaliko .br .PP This manual page was written for the Debian system (and may be used by others)\&. diff --git a/data/man/simadb_cli.1.xml b/data/man/simadb_cli.1.xml index 5448f86..6bab004 100644 --- a/data/man/simadb_cli.1.xml +++ b/data/man/simadb_cli.1.xml @@ -60,25 +60,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ &dhutils; is a command line interface editor for the sima user DB. - - &dhutils; - similarity_string - - - - - db_file - - - - - - mpd_host - - - mpd_port - - &dhutils; artist @@ -89,16 +70,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ - - &dhutils; - "main artist,similar artist" - - db_file - - - - - &dhutils; @@ -106,13 +77,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ db_file - - &dhutils; - - - db_file - - &dhutils; @@ -172,33 +136,12 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ This manual page documents briefly the &dhutils; commands. simadb_cli is a command line interface to get and edit users - similarities and blacklist database used with MPD_sima. The default + blacklist database used with MPD_sima. The default database file (see ) can be overridden if you want. - Consider reading to understand the - structure and relation of similarities within the database. EXAMPLE - - Similarity edition - Here follows some simple examples on how to deal with similarity database. - Pay attention, the following examples set one-way similarities in the DB! Read more about it in . - Adding a similarity between two artists. In the following example "Pelican" will point - to "Russian Circles" with a match score of 88% (ie. "Russian Circles" - 88% similar to Pelican, not reciprocal), it will also check against MPD - the presence of both artists in the music library. - &dhutils; --add "Pelican,Russian Circles:80" --check_names - Similarity string use comma "," as artists separator and semi colon ":" for - artist/similarity score separator, cf. . - Adding a similarity between multiple artists. In the following example "Rage - Against The Machine" will point to "Tool" and "Audioslave" as similar - artists and controls artists names are actually in MPD music library. - &dhutils; --add "Rage Against The Machine,Tool:70,Audiosalve:80" --check_names - Viewing similarit(y|ies) for an artist. In the - following example we are looking for entries for "Rage Against The Machine" - &dhutils; --view_artist "Rage Against The Machine" - Black list edition Adding to black list. You can add a single @@ -242,20 +185,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ Print version and exit. - - - - - Add similarity to the database.For more details about the similarity_string see . - - - - - - - Use with in order to check artists names used in similarity_string. &dhutils; will control presence of artists names in MPD library. Default is to look for MPD server on localhost:6600 or environment variables MPD_HOST and MPD_PORT if set.You can as well give &dhutils; host/port on the command line using respectively and . - - @@ -282,53 +211,18 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ Purge history, you may supply an alternative DB file with --dbfile option. - - - - - Use with an editing options in order to edit reciprocal similarity as well. and are supporting reciprocal edition. - N.B: this option has to appear after the editing option on the command line. - See for further information about reciprocity notion. - - - - - - Use to remove an artist entry (as main artist) with its associated similarities. To remove artist where it appears as a similar artist use the option. - - Use to remove a black list entry. To get the row_id to suppress use option. - - - - Use to remove a single similarity between a main artist and an associated similarity. Give the main artist first, use comma (",") to separate it from similar artist.Use of is possible here, see . - This option is useful in case you want to remove only a specific similarity between two artists, to remove completely an artist use instead. - - - - - - - Get entries for "artist name" in the data base (print to stdout). - - Get all entries in the black list. - - - - Get all entries in the data base (print to stdout). - - @@ -356,54 +250,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ - - SIMILARITY FORMAT - The similarity_string has to be formatted following a special pattern in order for simadb_cli to extract similarity relations between artists names. Usually a similarity entry is defined as a main artist, lets say main_art, followed by a list of similar artists which you want to be related to that main_art, each artist of that list with a specific similarity value, a match score, quantifying the similarity relation with the main_art. The match score value is an integer in [0 ,100] with 100 corresponding to a perfect match. - similarity_string is then to be formatted as follow: - main_art,first artist:<score>,second artist:<score> - Each artist group are separated with commas (",") and inside each group the artist name and the match score is colon (":") separated. Obviously the first artist group, as the main artist, does not have a match score. - Lets see how it works with an example. I consider "Led Zeppelin" to be similar to "Tool" with a match score of 25, I also want to have "Audioslave" related to "Led Zeppelin" with a score of 20. Then the similarity_string will be the following: - Led Zeppelin,Tool:25,Audiosalve:20 - See for more details about how similarities are handled - - - A WORD ABOUT SIMA DATA BASE - The similarity database is defined from the point of view of a main artist which is declared related to a list of similar artists. That means when you define main_art to be similar to sim_art A and sim_art B the reciprocal won't be true, sim_art A and sim_art B are not similar to main_art. At least this is the default behavior when you edit entries with simadb_cli, this is also the way last.fm is working concerning similar artists. This documentation is using that particular terminology to specify which kind of artist we are dealing with : "main artist" or "similar artist".The option allows one to add reciprocal relation where sim_art A and sim_art B become respectively the main_art. Using you will then edit two more entries in the database. To summarize here is what you'll end up with in your data base adding similarity with this string main_art,sim_art A:34,sim_art B:45. - simadb_cli --reciprocal --add_similarity=main_art,sim_art A:34,sim_art B:45 - main_art similar to sim_art A:34 and sim_art B:45sim_art A similar to main_art:34sim_art B similar to main_art:45 - Without the reciprocal option you would have add only the first similarity. Usually using the reciprocal option is the desired behavior, at least what users have in mind when thinking of similarity relation between to artists but keep in mind that it may lead to have MPD_sima more sensible to loop over the same two artist (ASSERTION TO BE CONFIRMED). - - diff --git a/doc/Changelog b/doc/Changelog index 8b121ee..b95ea7b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,11 @@ +MPD_sima v0.13.1 + + * Fixed default conf file name (back to mpd_sima.cfg) + * Cleanup code (removed users similarities) + +-- kaliko jack UNRELEASED + + MPD_sima v0.13.0 * Use of MusicBrainzIdentifier by default diff --git a/sima/info.py b/sima/info.py index 8225b84..aa879d4 100644 --- a/sima/info.py +++ b/sima/info.py @@ -11,7 +11,7 @@ queue is getting short. """ -__version__ = '0.13.0' +__version__ = '0.13.1' __author__ = 'kaliko jack' __email__ = 'kaliko@azylum.org' __url__ = 'git://git.kaliko.me/sima.git' diff --git a/sima/lib/simadb.py b/sima/lib/simadb.py index a7ce759..3eff0e8 100644 --- a/sima/lib/simadb.py +++ b/sima/lib/simadb.py @@ -28,7 +28,7 @@ # Artists: # -__DB_VERSION__ = 2 +__DB_VERSION__ = 3 __HIST_DURATION__ = int(30 * 24) # in hours import sqlite3 @@ -56,11 +56,6 @@ class SimaDBNoFile(SimaDBError): pass -class SimaDBUpgradeError(SimaDBError): - """Error on upgrade""" - pass - - class SimaDB(object): "SQLite management" @@ -95,23 +90,6 @@ class SimaDB(object): #connection.text_factory = str return connection - def upgrade(self): - """upgrade DB from previous versions""" - connection = self.get_database_connection() - try: - connection.execute('SELECT version FROM db_info') - except Exception as err: - if err.__str__() == "no such table: db_info": - # db version < 2 (MPD_sima 0.6) - copyfile(self._db_path, self._db_path + '.0.6') - connection.execute('DROP TABLE tracks') - connection.commit() - self.create_db() - else: - raise SimaDBUpgradeError('Could not upgrade database: "%s"' % - err) - self.close_database_connection(connection) - def get_artist(self, artist_name, mbid=None, with_connection=None, add_not=False): """get artist information from the database. @@ -422,8 +400,7 @@ class SimaDB(object): self.close_database_connection(connection) def _set_mbid(self, artist_id=None, mbid=None, with_connection=None): - """get artist information from the database. - if not in database insert new entry.""" + """""" if with_connection: connection = with_connection else: @@ -434,89 +411,6 @@ class SimaDB(object): if not with_connection: self.close_database_connection(connection) - def _get_similar_artists_from_db(self, artist_id): - connection = self.get_database_connection() - results = [row for row in connection.execute( - "SELECT match, name FROM usr_artist_2_artist INNER JOIN" - " artists ON usr_artist_2_artist.artist2 = artists.id WHERE" - " usr_artist_2_artist.artist1 = ? ORDER BY match DESC;", - (artist_id,))] - self.close_database_connection(connection) - for score, artist in results: - yield {'score': score, 'artist': artist} - - def _get_reverse_similar_artists_from_db(self, artist_id): - connection = self.get_database_connection() - results = [row for row in connection.execute( - "SELECT name FROM usr_artist_2_artist INNER JOIN" - " artists ON usr_artist_2_artist.artist1 = artists.id WHERE" - " usr_artist_2_artist.artist2 = ?;", - (artist_id,))] - self.close_database_connection(connection) - for artist in results: - yield artist[0] - - def get_similar_artists(self, artist_name): - """get similar artists from the database sorted by descending - match score""" - artist_id = self.get_artist(artist_name)[0] - for result in self._get_similar_artists_from_db(artist_id): - yield result - - def _get_artist_match(self, artist1, artist2, with_connection=None): - """get artist match score from database""" - if with_connection: - connection = with_connection - else: - connection = self.get_database_connection() - rows = connection.execute( - "SELECT match FROM usr_artist_2_artist WHERE artist1 = ?" - " AND artist2 = ?", - (artist1, artist2)) - result = 0 - for row in rows: - result = row[0] - break - if not with_connection: - self.close_database_connection(connection) - return result - - def _remove_relation_between_2_artist(self, artist1, artist2): - """Remove a similarity relation""" - connection = self.get_database_connection() - connection.execute( - 'DELETE FROM usr_artist_2_artist' - ' WHERE artist1 = ? AND artist2 = ?;', - (artist1, artist2)) - self.clean_database(with_connection=connection) - self._update_artist(artist_id=artist1, with_connection=connection) - connection.commit() - self.close_database_connection(connection) - - def _remove_artist(self, artist_id, deep=False, with_connection=None): - """Remove all artist1 reference""" - if with_connection: - connection = with_connection - else: - connection = self.get_database_connection() - if deep: - connection.execute( - 'DELETE FROM usr_artist_2_artist' - ' WHERE artist1 = ? OR artist2 = ?;', - (artist_id, artist_id)) - connection.execute( - 'DELETE FROM artists WHERE id = ?;', - (artist_id,)) - else: - connection.execute( - 'DELETE FROM usr_artist_2_artist WHERE artist1 = ?;', - (artist_id,)) - self.clean_database(with_connection=connection) - self._update_artist(artist_id=artist_id, with_connection=connection) - if not with_connection: - connection.commit() - self.close_database_connection(connection) - def _remove_bl(self, rowid): """Remove bl row id""" connection = self.get_database_connection() @@ -525,22 +419,6 @@ class SimaDB(object): connection.commit() self.close_database_connection(connection) - def _insert_artist_match( - self, artist1, artist2, match, with_connection=None): - """write match score to the database. - Does not update time stamp in table artist/*_updated""" - if with_connection: - connection = with_connection - else: - connection = self.get_database_connection() - connection.execute( - "INSERT INTO usr_artist_2_artist (artist1, artist2, match) VALUES" - " (?, ?, ?)", - (artist1, artist2, match)) - if not with_connection: - connection.commit() - self.close_database_connection(connection) - def add_history(self, track): """Add to history""" connection = self.get_database_connection() @@ -555,57 +433,6 @@ class SimaDB(object): connection.commit() self.close_database_connection(connection) - def _update_artist(self, artist_id, with_connection=None): - """write artist information to the database""" - if with_connection: - connection = with_connection - else: - connection = self.get_database_connection() - connection.execute( - "UPDATE artists SET usr_updated = DATETIME('now') WHERE id = ?", - (artist_id,)) - if not with_connection: - connection.commit() - self.close_database_connection(connection) - - def _update_artist_match( - self, artist1, artist2, match, with_connection=None): - """write match score to the database""" - if with_connection: - connection = with_connection - else: - connection = self.get_database_connection() - connection.execute( - "UPDATE usr_artist_2_artist SET match = ? WHERE artist1 = ? AND" - " artist2 = ?", - (match, artist1, artist2)) - if not with_connection: - connection.commit() - self.close_database_connection(connection) - - def _update_similar_artists(self, artist, similar_artists): - """write user similar artist information to the database - """ - # DOC: similar_artists = list([{'score': match, 'artist': name}]) - # - connection = self.get_database_connection() - artist_id = self.get_artist(artist, with_connection=connection)[0] - for artist in similar_artists: - id2 = self.get_artist( - artist['artist'], with_connection=connection)[0] - if self._get_artist_match( - artist_id, id2, with_connection=connection): - self._update_artist_match( - artist_id, id2, artist['score'], - with_connection=connection) - continue - self._insert_artist_match( - artist_id, id2, artist['score'], - with_connection=connection) - self._update_artist(artist_id, with_connection=connection) - connection.commit() - self.close_database_connection(connection) - def _clean_artists_table(self, with_connection=None): """Clean orphan artists""" if with_connection: @@ -615,10 +442,6 @@ class SimaDB(object): artists_ids = set([row[0] for row in connection.execute( "SELECT id FROM artists")]) artist_2_artist_ids = set([row[0] for row in connection.execute( - "SELECT artist1 FROM usr_artist_2_artist")] + - [row[0] for row in connection.execute( - "SELECT artist2 FROM usr_artist_2_artist")] + - [row[0] for row in connection.execute( "SELECT artist FROM black_list")] + [row[0] for row in connection.execute( "SELECT artist FROM albums")] + @@ -701,7 +524,7 @@ class SimaDB(object): self.close_database_connection(connection) def create_db(self): - """ Set up a database for the artist similarity scores + """ Set up a database """ connection = self.get_database_connection() connection.execute( @@ -709,13 +532,7 @@ class SimaDB(object): ' (version INTEGER, name CHAR(36))') connection.execute( 'CREATE TABLE IF NOT EXISTS artists (id INTEGER PRIMARY KEY, name' - ' VARCHAR(100), mbid CHAR(36), lfm_updated DATE, usr_updated DATE)') - connection.execute( - 'CREATE TABLE IF NOT EXISTS usr_artist_2_artist (artist1 INTEGER,' - ' artist2 INTEGER, match INTEGER)') - connection.execute( - 'CREATE TABLE IF NOT EXISTS lfm_artist_2_artist (artist1 INTEGER,' - ' artist2 INTEGER, match INTEGER)') + ' VARCHAR(100), mbid CHAR(36))') connection.execute( 'CREATE TABLE IF NOT EXISTS albums (id INTEGER PRIMARY KEY,' ' artist INTEGER, name VARCHAR(100), mbid CHAR(36))') @@ -729,28 +546,10 @@ class SimaDB(object): connection.execute( 'CREATE TABLE IF NOT EXISTS history (last_play DATE,' ' track integer)') - connection.execute( - "CREATE INDEX IF NOT EXISTS a2aa1x ON usr_artist_2_artist (artist1)") - connection.execute( - "CREATE INDEX IF NOT EXISTS a2aa2x ON usr_artist_2_artist (artist2)") - connection.execute( - "CREATE INDEX IF NOT EXISTS lfma2aa1x ON lfm_artist_2_artist (artist1)") - connection.execute( - "CREATE INDEX IF NOT EXISTS lfma2aa2x ON lfm_artist_2_artist (artist2)") connection.commit() self.close_database_connection(connection) self._set_dbversion() -def main(): - db = SimaDB(db_path='/tmp/sima.db') - db.purge_history(int(4)) - db.clean_database() - - -# Script starts here -if __name__ == '__main__': - main() - # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/sima/utils/config.py b/sima/utils/config.py index fdf17eb..bf370f1 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -50,7 +50,7 @@ DEFAULT_CONF = { 'contrib': "", 'user_db': "false", 'history_duration': 8, - 'queue_length': 1, + 'queue_length': 2, 'var_dir': 'empty', 'musicbrainzid': "true", }, diff --git a/simadb_cli b/simadb_cli index 52f45bc..c57e130 100755 --- a/simadb_cli +++ b/simadb_cli @@ -43,68 +43,15 @@ simadb_cli helps you to edit entries in your own DB of similarity between artists.""" DB_NAME = 'sima.db' -class FooAction(Action): - def check(self, namespace): - if namespace.similarity: return True - if namespace.remove_art: return True - if namespace.remove_sim: return True - - def __call__(self, parser, namespace, values, option_string=None): - opt_required = '"--remove_artist", "--remove_similarity" or "--add_similarity"' - if not self.check(namespace): - parser.error( - 'can\'t use {0} option before or without {1}'.format( - option_string, opt_required)) - setattr(namespace, self.dest, True) - # Options list # pop out 'sw' value before creating ArgumentParser object. OPTS = list([ - { - 'sw':['-a', '--add_similarity'], - 'type': str, - 'dest':'similarity', - 'help': 'Similarity to add formated as follow: ' + - ' "art_0,art_1:90,art_2:80..."'}, - { - 'sw': ['-c', '--check_names'], - 'action': 'store_true', - 'default': False, - 'help': 'Turn on controls of artists names in MPD library.'}, { 'sw':['-d', '--dbfile'], 'type': str, 'dest':'dbfile', 'action': utils.Wfile, 'help': 'File to read/write database from/to'}, - { - 'sw': ['-r', '--reciprocal'], - 'default': False, - 'nargs': 0, - 'action': FooAction, - 'help': 'Turn on reciprocity for similarity relation when add/remove.'}, - { - 'sw':['--remove_artist'], - 'type': str, - 'dest': 'remove_art', - 'metavar': '"ARTIST TO REMOVE"', - 'help': 'Remove an artist from DB (main artist entries).'}, - { - 'sw':['--remove_similarity'], - 'type': str, - 'dest': 'remove_sim', - 'metavar': '"MAIN ART,SIMI ART"', - 'help': 'Remove an similarity relation from DB (main artist <=> similar artist).'}, - { - 'sw':['-v', '--view_artist'], - 'type': str, - 'dest':'view', - 'metavar': '"ARTIST NAME"', - 'help': 'View an artist from DB.'}, - { - 'sw':['--view_all'], - 'action': 'store_true', - 'help': 'View all similarity entries.'}, { 'sw': ['-S', '--host'], 'type': str, @@ -306,54 +253,6 @@ class SimaDB_CLI(object): mpd_cli.disconnect() return control - def _parse_similarity(self): - """Parse command line option similarity""" - cli_sim = self.options.similarity.strip(',').split(',') - sim = list([]) - main = cli_sim[0] - for art in cli_sim[1:]: - artist = art.split(':')[0] - score = int(art.split(':')[1]) - sim.append({'artist': artist, 'score': score}) - return (main, sim) - - def _print_main_art(self, art=None): - """Print entries, art as main artist.""" - if not art: - art = self.options.view - db = simadb.SimaDB(db_path=self.dbfile) - art_db = self._get_art_from_db(art) - if not art_db: return - sims = list([]) - [sims.append(a) for a in db._get_similar_artists_from_db(art_db[0])] - if len(sims) == 0: - return False - print('"%s" similarities:' % art) - for art in sims: - mess = str(' - {score:0>2d} {artist}'.format(**art)) - print(mess) - return True - - def _remove_sim(self, art1_db, art2_db): - """Remove single similarity between two artists.""" - db = simadb.SimaDB(db_path=self.dbfile) - similarity = db._get_artist_match(art1_db[0], art2_db[0]) - if similarity == 0: - return False - db._remove_relation_between_2_artist(art1_db[0], art2_db[0]) - mess = 'Remove: "{0}" "{1}:{2:0>2d}"'.format(art1_db[1], art2_db[1], - similarity) - print(mess) - return True - - def _revert_similarity(self, sim_formated): - """Revert similarity string (for reciprocal editing - add).""" - main_art = sim_formated[0] - similars = sim_formated[1] - for similar in similars: - yield (similar.get('artist'), - [{'artist':main_art, 'score':similar.get('score')}]) - def bl_artist(self): """Black list artist""" mpd_cli = self._get_mpd_client() @@ -419,31 +318,6 @@ class SimaDB_CLI(object): db.clean_database() print('done.') - def view(self): - """Print out entries for an artist.""" - art = self.options.view - db = simadb.SimaDB(db_path=self.dbfile) - art_db = self._get_art_from_db(art) - if not art_db: return - if not self._print_main_art(): - mess = str('"%s" present in DB but not as a main artist' % art) - print(mess) - else: print('') - art_rev = list([]) - [art_rev.append(a) for a in db._get_reverse_similar_artists_from_db(art_db[0])] - if not art_rev: return - mess = str('%s" appears as similar for the following artist(s): %s' % - (art,', '.join(art_rev))) - print(mess) - [self._print_main_art(a) for a in art_rev] - - def view_all(self): - """Print out all entries.""" - db = simadb.SimaDB(db_path=self.dbfile) - for art in db.get_artists(): - if not art[0]: continue - self._print_main_art(art=art[0]) - def view_bl(self): """Print out black list.""" # TODO: enhance output formating @@ -451,60 +325,11 @@ class SimaDB_CLI(object): for bl_e in db.get_black_list(): print('\t# '.join([str(e) for e in bl_e])) - def remove_similarity(self): - """Remove entry""" - cli_sim = self.options.remove_sim - pattern = '^([^,]+?),([^,]+?,?)$' - regexp = re.compile(pattern, re.U).match(cli_sim) - if not regexp: - print('ERROR: similarity badly formated: "%s"' % cli_sim, file=stderr) - print('USAGE: A single relation between two artists is expected here.', file=stderr) - print('USAGE: "main artist,similar artist"', file=stderr) - exit(1) - arts = cli_sim.split(',') - if len(arts) != 2: - print('ERROR: unknown error in similarity format', file=stderr) - print('USAGE: "main artist,similar artist"', file=stderr) - exit(1) - art1_db = self._get_art_from_db(arts[0].strip()) - art2_db = self._get_art_from_db(arts[1].strip()) - if not art1_db or not art2_db: return - self._remove_sim(art1_db, art2_db) - if not self.options.reciprocal: - return - self._remove_sim(art2_db, art1_db) - - def remove_artist(self): - """ Remove artist in the DB.""" - deep = False - art = self.options.remove_art - db = simadb.SimaDB(db_path=self.dbfile) - art_db = self._get_art_from_db(art) - if not art_db: return False - print('Removing "%s" from database' % art) - if self.options.reciprocal: - print('reciprocal option used, performing deep remove!') - deep = True - db._remove_artist(art_db[0], deep=deep) - def remove_black_list_entry(self): """""" db = simadb.SimaDB(db_path=self.dbfile) db._remove_bl(int(self.options.remove_bl)) - def write_simi(self): - """Write similarity to DB. - """ - self._create_db() - sim_formated = self._parse_similarity() - print('About to update DB with: "%s": %s' % sim_formated) - db = simadb.SimaDB(db_path=self.dbfile) - db._update_similar_artists(*sim_formated) - if self.options.reciprocal: - print('...and with reciprocal combinations as well.') - for sim_formed_rec in self._revert_similarity(sim_formated): - db._update_similar_artists(*sim_formed_rec) - def main(self): """ Parse command line and run actions. @@ -515,8 +340,6 @@ class SimaDB_CLI(object): if self.options.dbfile: self.dbfile = self.options.dbfile print('Using db file: %s' % self.dbfile) - if self.options.reciprocal: - print('Editing reciprocal similarity') if self.options.bl_art: self.bl_artist() return @@ -535,21 +358,6 @@ class SimaDB_CLI(object): if self.options.remove_bl: self.remove_black_list_entry() return - if self.options.similarity: - self._control_similarity() - self.write_simi() - return - if self.options.remove_art: - self.remove_artist() - return - if self.options.remove_sim: - self.remove_similarity() - return - if self.options.view: - self.view() - return - if self.options.view_all: - self.view_all() if self.options.do_purge_hist: self.purge_history() exit(0)