playlist debugged

This commit is contained in:
Azlux
2018-11-21 00:22:06 +01:00
parent b872f86fba
commit d62adec9e3
6 changed files with 140 additions and 73 deletions

View File

@ -0,0 +1,35 @@
import youtube_dl
import variables as var
def get_playlist_info():
ydl_opts = {
'playlist_items': str(0)
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for i in range(2):
try:
info = ydl.extract_info(var.playlist[-1]['url'], download=False)
var.playlist[-1]['playlist_title'] = info['title']
except youtube_dl.utils.DownloadError:
pass
else:
return True
return False
def get_music_info(index=0):
ydl_opts = {
'playlist_items': str(index)
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for i in range(2):
try:
info = ydl.extract_info(var.playlist[0]['url'], download=False)
var.playlist[0]['current_duration'] = info['entries'][0]['duration'] / 60
var.playlist[0]['current_title'] = info['entries'][0]['title']
except youtube_dl.utils.DownloadError:
pass
else:
return True
return False

View File

@ -26,7 +26,6 @@ def clear_tmp_folder(path, size):
all_files = [os.path.join(path, file) for file in files]
all_files.sort(key=lambda x: os.path.getmtime(x))
size_tp = 0
print(all_files)
for idx, file in enumerate(all_files):
size_tp += os.path.getsize(file)
if int(size_tp / (1024 * 1024)) > size: