Use YouTube as fallback for track metadata if not found on Spotify

This commit is contained in:
Ritiek Malhotra
2018-12-31 19:12:54 +05:30
parent ddb4b01897
commit eb77880f9f
5 changed files with 84 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
from logzero import logger as log
import os
import sys
import urllib.request
from spotdl import const
@@ -253,3 +254,12 @@ def remove_duplicates(tracks):
local_set = set()
local_set_add = local_set.add
return [x for x in tracks if not (x in local_set or local_set_add(x))]
def content_available(url):
try:
response = urllib.request.urlopen(url)
except HTTPError:
return False
else:
return response.getcode() < 300