diff --git a/command.py b/command.py index f94300e..581c6e5 100644 --- a/command.py +++ b/command.py @@ -59,7 +59,7 @@ def register_all_commands(bot): bot.register_command(constants.commands('remove_tag'), cmd_remove_tag) bot.register_command(constants.commands('find_tagged'), cmd_find_tagged) bot.register_command(constants.commands('drop_database'), cmd_drop_database, True) - bot.register_command(constants.commands('recache'), cmd_refresh_cache, True) + bot.register_command(constants.commands('rescan'), cmd_refresh_cache, True) # Just for debug use bot.register_command('rtrms', cmd_real_time_rms, True) @@ -904,7 +904,7 @@ def cmd_drop_database(bot, user, text, command, parameter): def cmd_refresh_cache(bot, user, text, command, parameter): global log var.library.build_dir_cache(bot) - log.info("command: cache refreshed.") + log.info("command: Local file cache refreshed.") bot.send_msg(constants.strings('cache_refreshed'), text) # Just for debug use diff --git a/configuration.default.ini b/configuration.default.ini index 508cbd8..ff2ffa3 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -171,7 +171,7 @@ ducking_threshold = duckthres ducking_volume = duckv drop_database = dropdatabase -recache = recache +rescan = rescan [strings] current_volume = Current volume: {volume}. @@ -259,10 +259,11 @@ help =

Commands

+ Tag +
  • !addtag {index} {tags} - add {tags} to {index}-th item on the playlist, tags separated by ",".
  • +
  • !addtag * {tags} - add {tags} to all items on the playlist.
  • +
  • !untag {index/*} {tags} - remove {tags} from {index}-th item on the playlist.
  • +
  • !untag {index/*} * - remove all tags from {index}-th item on the playlist.
  • +
  • !findtagged (or !ft) {tags} - find item with {tags} in the music library.
  • Other diff --git a/database.py b/database.py index 9bcc94a..11d5983 100644 --- a/database.py +++ b/database.py @@ -219,7 +219,6 @@ class MusicDatabase: else: return None - def query_music_by_tags(self, tags): condition = [] filler = [] @@ -251,6 +250,20 @@ class MusicDatabase: else: return None + def query_tags_by_id(self, id): + conn = sqlite3.connect(self.db_path) + cursor = conn.cursor() + results = cursor.execute("SELECT tags FROM music " + "WHERE id=?", (id, )).fetchall() + conn.close() + + if len(results) > 0: + tags = results[0][0].strip(",").split(",") + + return tags + else: + return None + def delete_music(self, **kwargs): condition = [] filler = [] diff --git a/interface.py b/interface.py index 1cd43aa..dc492b2 100644 --- a/interface.py +++ b/interface.py @@ -90,12 +90,20 @@ def requires_auth(f): return f(*args, **kwargs) return decorated +def build_tags_lookup(): + lookup = {} + for path, id in var.library.file_id_lookup.items(): + lookup[path] = var.music_db.query_tags_by_id(id) + + return lookup @web.route("/", methods=['GET']) @requires_auth def index(): + tags_lookup = build_tags_lookup() return render_template('index.html', all_files=var.library.files, + tags_lookup=tags_lookup, music_library=var.library.dir, os=os, playlist=var.playlist, @@ -272,6 +280,9 @@ def post(): var.playlist = media.playlist.get_playlist("autoplay", var.playlist) var.db.set('playlist', 'playback_mode', "autoplay") log.info("web: playback mode changed to autoplay.") + if action == "rescan": + var.library.build_dir_cache(var.bot) + log.info("web: Local file cache refreshed.") elif action == "stop": var.bot.stop() elif action == "pause": diff --git a/static/css/custom.css b/static/css/custom.css index c826894..7b49d00 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,4 +1,5 @@ .bs-docs-section{margin-top:4em} .btn-space{margin-right:5px} -.playlist-title{display:inline-block} -.playlist-artwork{display:inline-block; margin-left:5px;} +.playlist-title-td{width:60%} +.playlist-title{float:left; } +.playlist-artwork{float:left; margin-left:10px;} diff --git a/templates/index.html b/templates/index.html index d2f7d28..5e3e88f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -74,7 +74,13 @@ -
    {{ filepath }}
    +
    +
    + {{ filepath }} +
    + {% for tag in tags_lookup[filepath] %} + {{ tag }} + {% endfor %}
    @@ -175,7 +181,7 @@ # - Title + Title Url/Path Action @@ -209,6 +215,10 @@
    + diff --git a/templates/playlist.html b/templates/playlist.html index 03bf9ff..bfe9c0c 100644 --- a/templates/playlist.html +++ b/templates/playlist.html @@ -24,7 +24,7 @@ {{ m.url|truncate(45) }} {% endif %} {{ m.display_type() }} -
    +
    {% if m.type == 'file' %} {% if m.artist %} {{ m.artist }} @@ -36,6 +36,10 @@ {% else %} Unknown Artist {% endif %} +
    + {% for tag in m.tags %} + {{ tag }} + {% endfor %}