You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB
Python

from pydub import AudioSegment
from pydub.utils import mediainfo
import pprint
import argparse
ap = argparse.ArgumentParser("metadatatohtml")
ap.add_argument("mp3")
args = ap.parse_args()
z = mediainfo(args.mp3)
# sound= AudioSegment.from_file("podcasts/3_podcast.mp3", format="mp3")
# file=sound.export("out.mp3", tags={"podcaster":"lain"})
# print (mediainfo("out.mp3"))
def dict_to_html(dd, level=0):
"""
Convert dict to html using basic html tags
"""
import simplejson
text = ''
for k, v in dd.items():
text += '<br>' + '&nbsp;'*(4*level) + '<b>%s</b>: %s' % (k, dict_to_html(v, level+1) if isinstance(v, dict) else (simplejson.dumps(v) if isinstance(v, list) else v))
return text
def dict_to_html_ul(dd, level=0):
"""
Convert dict to html using ul/li tags
"""
import simplejson
text = '<ul>'
for k, v in dd.items():
text += '<li><b>%s</b>: %s</li>' % (k, dict_to_html_ul(v, level+1) if isinstance(v, dict) else (simplejson.dumps(v) if isinstance(v, list) else v))
text += '</ul>'
return text
print (dict_to_html_ul(z, level=0))