scripts / checkmusic /
d509f19 7 years ago
1 contributor
41 lines | 1.178kb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# piece of code modified from file metainfo.py from:
# CherryMusic - a standalone music server (http://github.com/devsnd/cherrymusic/) # Copyright (c) 2012 - 2016 Tom Wallroth & Tilman Boerner
# Thanks to them for their very nice music server
#
import sys
from tinytag import TinyTag

class Metainfo():
    def __init__(self, artist='', album='', title='', track='', length=0):
        self.artist = artist
        self.album = album
        self.title = title
        self.track = track
        self.length = length

    def dict(self):
        return {
            'artist': self.artist,
            'album': self.album,
            'title': self.title,
            'track': self.track,
            'length': self.length
        }

def getSongInfo(filepath):
    print(filepath, end=": ")
    try:
        tag = TinyTag.get(filepath)
    except LookupError:
        return Metainfo()
    for attribute in ['artist','album','title','track']:
        if getattr(tag, attribute) is None:
            print(attribute, end=" ")
    print()

if __name__ == "__main__":
    for filepath in sys.argv[1:]:
        getSongInfo(filepath)