Skip to content

Instantly share code, notes, and snippets.

@LoneRabbit
Created May 8, 2022 17:04
Show Gist options
  • Save LoneRabbit/554e601c8950e022ca49c69ee8ee00cc to your computer and use it in GitHub Desktop.
Save LoneRabbit/554e601c8950e022ca49c69ee8ee00cc to your computer and use it in GitHub Desktop.
Tracklisting script for timestamps on YouTube playlist videos, with artists. Only works with .mp3 files with title and artist metadata.
path.strip('"') #Remove quotes
title = []
trackno = []
length = []
artist = []
#PARSING
for root, dirs, files in os.walk(os.path.abspath(path)):
for file in files:
if file.endswith(".mp3"):
#print(os.path.join(root, file))
#Mutagen:
##audio = MP3(os.path.join(root, file))
##title = TIT2(os.path.join(root, file))
##length = audio.info.length
#EyeD3:
title.append(eyed3.load(os.path.join(root, file)).tag.title)
trackno.append((eyed3.load(os.path.join(root, file)).tag.track_num)[0])
length.append(eyed3.load(os.path.join(root, file)).info.time_secs)
artist.append(eyed3.load(os.path.join(root, file)).tag.artist)
ntrack = ntrack + 1
for i in range(ntrack):
for x in range(ntrack):
if trackno[x] == (i+1):
minute = int(cumlength//60)
remainder = str(int(cumlength % 60))
remainder = remainder.zfill(2)
if minute >=60:
hour = minute//60
minute = minute-(60*hour)
print(hour, ":", minute, ":", remainder, " ", artist[x], " - ", title[x], sep='')
else:
print(minute, ":", remainder, " ", artist[x], " - ", title[x], sep='')
cumlength = cumlength + length[x] #CUMulative length
#Conclusion: This probably took me way more time than to just actually do it manually. Did this from around 3 or 4pm now it's 5pm.
#And I took another day to make it list in the correct order... OMG I finally did it. My god.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment