Items can requests their download URL by themselves

This commit is contained in:
Manuel Cortez 2018-01-26 11:52:18 -06:00
parent 86cfb3bf94
commit c9a832b6ee
2 changed files with 7 additions and 3 deletions

View File

@ -4,7 +4,8 @@
class song(object):
""" Represents a song in all services. Data will be filled by the service itself"""
def __init__(self):
def __init__(self, extractor):
self.extractor = extractor
self.bitrate = 0
self.title = ""
self.artist = ""
@ -14,4 +15,7 @@ class song(object):
self.download_url = ""
def format_track(self):
return "{0}. {1}. {2}".format(self.title, self.duration, self.size)
return "{0}. {1}. {2}".format(self.title, self.duration, self.size)
def get_download_url(self):
self.download_url = self.extractor.get_download_url(self.url)

View File

@ -22,7 +22,7 @@ class interface(object):
self.hd = [{'duration': re.search(D, str(x)).group()[13:], 'size': re.search(R, str(x)).group()[7:], 'bitrate': re.search(B, str(x)).group()[8:]} for x in soup.find_all('div', {'class': "result__snp"})]
self.results = []
for i in range(len(self.hd)):
s = baseFile.song()
s = baseFile.song(self)
s.title = self.dh[i][0]
s.url = self.dh[i][1]
s.duration = self.hd[i]["duration"]