Permalink
Browse files

added collecting unused tags

unused toptags are written to a sqlite db file in ~/.config/MusicBrainz/toptags.db
this can be deactivated eith the global option collect_unused = False
to read the 10 top most unused tags use the readtags.py script
eg. readtags.py 10
  • Loading branch information...
1 parent dc09f27 commit 1bc193a5e5945c58b6f110f1d51806f55e9c00b4 @fdemmer committed Nov 9, 2011
Showing with 104 additions and 14 deletions.
  1. +52 −3 lastfmng/__init__.py
  2. +29 −11 lastfmng/config.ini
  3. +23 −0 lastfmng/readtags.py
View
@@ -53,7 +53,7 @@
# on album level set the following metadata
'album': {
# multiplication factors for each type of toptag
- 'weight': dict(album=25, all_artist=45, all_track=30),
+ 'weight': dict(album=20, all_artist=55, all_track=25),
'tags': {
# category metatag
'grouping': 'albumgrouping',
@@ -115,7 +115,7 @@
# enabled: don't collect toptags for that category
# sort: alphabetically sort toptags before joining to string
# titlecase: apply titlecase() function to each toptag
- # separator: used to join toptags if >1 are to be used
+ # separator: used to join toptags if >1 are to be used (None to use multtag)
# unknown: the string to use if no toptag was found for the category
# overflow: name of another category, unused toptags in this category
# will be used in the given one.
@@ -146,7 +146,7 @@
# country names
('country', dict(
searchlist=StringSearchlist(config.get('searchlist', 'country')),
- limit=1, threshold=0.7, enabled=True, sort=True, titlecase=True,
+ limit=2, threshold=0.7, enabled=True, sort=True, titlecase=True,
separator=None, unknown="Unknown")),
# city names
('city', dict(
@@ -426,6 +426,51 @@ def print_toptag_stats(self, scope, name, correction=1):
merged = merge_tags((toptags, correction))[:10]
self.print_toplist(merged)
+ def collect_unused(self):
+ all_tags = merge_tags(
+ (self.toptags['album'], 1),
+ (self.toptags['track'], 1),
+ (self.toptags['artist'], 1),
+ (self.toptags['all_track'], 1),
+ (self.toptags['all_artist'], 1)
+ )
+
+ searchlists = [opt['searchlist'] for cat, opt in CATEGORIES.items()]
+ unknown_toptags = []
+
+ for toptag in all_tags:
+ tag, score = toptag
+ for searchlist in searchlists:
+ if tag in searchlist:
+ toptag = None
+ break
+ if toptag is not None:
+ unknown_toptags.append(toptag)
+
+ import sqlite3
+ conn = sqlite3.connect(os.path.expanduser('~/.config/MusicBrainz/toptags.db'))
+ c = conn.cursor()
+
+ try:
+ c.execute("""
+ create table toptags (tag text primary key, score integer)
+ """)
+ except:
+ pass
+
+ #for t in unknown_toptags:
+ # c.execute('insert into toptags values (?,?)', t)
+
+ for tag, score in unknown_toptags:
+ c.execute("""
+ replace into toptags (tag, score)
+ values (?,
+ coalesce((select score from toptags where tag = ?),0)+?)
+ """, (tag, tag, score))
+
+ conn.commit()
+ c.close()
+
def filter_and_set_metadata(self, scope, all_tags, stats=False):
"""
processing of a merged toptag list:
@@ -526,6 +571,8 @@ def process_album_tags(self):
self.filter_and_set_metadata('album', all_tags,
stats=config.getboolean('global', 'print_tag_stats_album'))
+ if config.getboolean('global', 'collect_unused'):
+ self.collect_unused()
def process_track_tags(self):
"""
@@ -548,6 +595,8 @@ def process_track_tags(self):
self.filter_and_set_metadata('track', all_tags,
stats=config.getboolean('global', 'print_tag_stats_track'))
+ if config.getboolean('global', 'collect_unused'):
+ self.collect_unused()
def encode_str(s):
return QtCore.QUrl.toPercentEncoding(s)
View
@@ -4,6 +4,7 @@ soundtrack_is_no_genre = True
print_tag_stats = True
print_tag_stats_album = True
print_tag_stats_track = False
+collect_unused = True
;remove_grouping_from_genre = True
[searchlist]
@@ -32,14 +33,15 @@ major_genre = Blues, Classic Rock, Country, Dance, Disco, Funk,
Polsk Punk, Beat, Heavy Metal,
Black Metal, Crossover,
Merengue, Salsa, Trash Metal, Anime, Jpop, Synthpop
+;;; removed from "standard" list, because i do not like them :P
; Top 40, Christian Rap, Other, Negerpunk, Christian Rock,
; Contemporary Christian, Christian Gangsta Rap, BritPop,
# minor genre should *not* also contain tags from major!
minor_genre = 2 tone, a cappella, abstract hip-hop, acid, acid jazz,
- acid rock, acoustic, acoustic guitar, acoustic rock, adult alternative,
+ acid rock, acid house, acoustic guitar, acoustic rock, adult alternative,
adult contemporary, alternative country, alternative folk,
- alternative metal, alternative pop, anti-folk,
+ alternative metal, alternative pop, anti-folk, britpop,
art rock, atmospheric, aussie hip-hop, avant-garde, ballads, baroque, beach,
beats, bebop, big band, blaxploitation, blue-eyed soul, bluegrass, blues
rock, boogie rock, boogie woogie, bossa nova, breakbeat, breaks, brit pop,
@@ -62,7 +64,7 @@ minor_genre = 2 tone, a cappella, abstract hip-hop, acid, acid jazz,
vocal, jungle, latin, latin jazz, latin pop, lounge, lovers rock, lullaby,
madchester, mambo, medieval, melodic rock, minimal, modern country, modern
rock, mood music, motown, neo-soul, new age, new romantic, new wave, noise,
- northern soul, nu metal, old school rap, opera, orchestral, philly soul,
+ northern soul, nu-metal, old school rap, opera, orchestral, philly soul,
piano, political reggae, polka, pop life, pop punk, pop rock, pop soul, post
punk, post rock, power pop, progressive, psychedelic,
psychedelic folk, psychedelic punk, psychedelic rock, psychobilly,
@@ -74,39 +76,41 @@ minor_genre = 2 tone, a cappella, abstract hip-hop, acid, acid jazz,
synth pop, tango, techno, teen pop, thrash metal, traditional country,
traditional folk, tribal, turntablism, underground, underground
hip-hop, underground rap, urban, vocal trance, waltz, west coast rap,
- western swing, world, world fusion, power metal
+ western swing, world, world fusion, power metal, alternative punk,
+ post punk, folktronica, glam
mood = angry, bewildered, bouncy, calm, cheerful, chill, cold,
- complacent, crazy, crushed, cynical, depressed, dramatic, dreamy, drunk,
+ complacent, crazy, crushed, cynical, dark, dramatic, dreamy, drunk,
eclectic, emotional, energetic, envious, feel good, flirty, funky, groovy,
happy, haunting, healing, high, hopeful, hot, humorous, inspiring, intense,
irritated, laidback, lonely, lovesongs, meditation, melancholic, melancholy,
mellow, moody, morose, passionate, peace, peaceful, playful, pleased,
positive, quirky, reflective, rejected, relaxed, retro, sad, sentimental,
sexy, silly, smooth, soulful, spiritual, suicidal, surprised, sympathetic,
- trippy, upbeat, uplifting, weird, wild, yearning
+ trippy, upbeat, uplifting, weird, wild, yearning, catchy, nostalgic,
+ heartbreaking, lovely, depressive, cool, slow, sweet, soft, fun
occasion = background, birthday, breakup, carnival, chillout,
christmas, death, dinner, drinking, driving, graduation, halloween, hanging
out, heartache, holiday, late night, love, new year, party, protest, rain,
rave, romantic, sleep, spring, summer, sunny, twilight, valentine, wake up,
wedding, winter, work
-category = animal songs, attitude, autumn, b-side, ballad,
+category = animal songs, amazing, awesome, attitude, autumn, b-side, ballad,
banjo, bass, beautiful, body parts, bootlegs, brass, cafe del mar, chamber
music, clarinet, classic, classic tunes, compilations, covers, cowbell,
deceased, demos, divas, dj, drugs, drums, duets, field recordings, female,
- female vocalists, film score, flute, food, genius, girl group, great lyrics,
+ female vocalist, film score, flute, food, genius, girl group, great lyrics,
guitar solo, guitarist, handclaps, harmonica, historical, horns, hypnotic,
influential, insane, jam, keyboard, legends, life, linedance, live, loved,
- lyricism, male, male vocalists, masterpiece, melodic, memories, musicals,
+ lyricism, male, male vocalist, masterpiece, melodic, memories, musicals,
nostalgia, novelty, number songs, old school, oldie, oldies, one hit
wonders, orchestra, organ, parody, poetry, political, promos, radio
programs, rastafarian, remix, samples, satire, saxophone, showtunes,
sing-alongs, singer-songwriter, slide guitar, solo instrumentals, songs with
names, soundtracks, speeches, stories, strings, stylish, synth, title is a
full sentence, top 40, traditional, trumpet, unique, unplugged, violin,
- virtuoso, vocalization, vocals
+ virtuoso, vocalization, vocals, cover, epic
country = african, american, arabic, australian, austrian,
belgian, brazilian, british, canadian, caribbean, celtic, chinese, cuban,
@@ -115,7 +119,8 @@ country = african, american, arabic, australian, austrian,
island, israeli, italian, jamaican, japanese, korean, mexican, middle
eastern, new zealand, norwegian, oriental, polish, portuguese, russian,
scandinavian, scottish, southern, spanish, swedish, swiss, thai, third
- world, turkish, welsh, western, texas
+ world, turkish, welsh, western, texas, uk, belgium, england, scotland,
+ usa
city = acapulco, adelaide, amsterdam, athens, atlanta,
atlantic city, auckland, austin, bakersfield, bali, baltimore, bangalore,
@@ -145,14 +150,27 @@ city = acapulco, adelaide, amsterdam, athens, atlanta,
[translations]
; <name1> is translated into <name2>
+female vocalists = female vocalist
+male vocalists = male vocalist
drum 'n' bass = drum and bass
drum n bass = drum and bass
rock and roll = rock & roll
trip hop = trip-hop
+hip hop = hip-hop
+nu metal = nu-metal
melancholic = melancholy
electro = electronic
+electronica = electronic
acoustic guitar = guitar
brit pop = britpop
j-pop = jpop
j-rock = jrock
+post-punk = post punk
+post-rock = post rock
+english = england
+sex = sexy
+depressed = depressive
+deutsch = german
+relax = relaxed
+relaxing = relaxed
View
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+import os
+import sys
+import sqlite3
+
+try:
+ count = sys.argv[1]
+except:
+ count = 10
+
+try:
+ conn = sqlite3.connect(os.path.expanduser('~/.config/MusicBrainz/toptags.db'))
+ c = conn.cursor()
+
+ c.execute('''select * from toptags order by score desc limit ?''', (count,))
+
+ for row in c:
+ print "{} ({})".format(row[0], row[1])
+
+ c.close()
+except:
+ print "database error"

0 comments on commit 1bc193a

Please sign in to comment.