Skip to content

Commit

Permalink
Add scripts to check music tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodebo committed Apr 18, 2018
1 parent 6720cde commit 077aa9b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
52 changes: 52 additions & 0 deletions bin/check_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python3

import traceback
import os
from mpd import MPDClient


def checktag():
client = MPDClient()

mpd_host = 'localhost'
mpd_port = '6600'
mpd_pass = ''

if 'MPD_HOST' in os.environ:
mpd_connection = os.environ['MPD_HOST'].split('@')
if len(mpd_connection) == 1:
mpd_host = mpd_connection[0]
elif len(mpd_connection) == 2:
mpd_host = mpd_connection[1]
mpd_pass = mpd_connection[0]
else:
print('Unable to parse MPD_HOST, using defaults')

if 'MPD_PORT' in os.environ:
mpd_port = os.environ['MPD_PORT']

client.connect(mpd_host, mpd_port)
if mpd_pass:
client.password(mpd_pass)

search = input("Which tag to search for? (album, albumartist, date)> ")
tagpool = client.search('filename', '')

for tag in tagpool:
newpool = []
if 'directory' not in tag:
if search not in tag:
newpool.append(tag)
for entry in newpool:
if 'file' in entry:
print(entry['file'])


def main():
checktag()


try:
main()
except Exception as e:
print(traceback.format_exc())
14 changes: 14 additions & 0 deletions bin/chktags
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

main () {
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local activate
pybin="$MPD2_PYLIB/bin/python"
if ! [[ -s "$pybin" ]]; then
python -m venv "$MPD2_PYLIB"
"$MPD2_PYLIB/bin/pip" install python-mpd2 -U
fi
"$MPD2_PYLIB/bin/python" "$SCRIPT_DIR/check_tags.py"
}

main

0 comments on commit 077aa9b

Please sign in to comment.