def fill_media(self, media, fields): if fields != ['thumbnail'] and fields != ['url']: # if we don't want only the thumbnail, we probably want also every fields if isinstance(media, BaseVideo): media = self.browser.get_video(media.id, media) else: _id = BaseAudio.decode_id(media.id) media = self.browser.get_audio(_id, media) if 'url' in fields and not media.url: _id = BaseAudio.decode_id(media.id) if isinstance(media, BaseAudio) else media.id media.url = self.browser.get_media_url(_id) if 'thumbnail' in fields and media.thumbnail: media.thumbnail.data = self.browser.open(media.thumbnail.url).content return media
def fill_audio(self, audio, fields): if 'url' in fields: with self.browser: _id = BaseAudio.decode_id(audio.id) audio.url = unicode(self.browser.get_stream_url_from_song_id(_id)) if 'thumbnail' in fields and audio.thumbnail: with self.browser: audio.thumbnail.data = self.browser.readurl(audio.thumbnail.url)
def __init__(self, *args, **kwargs): BaseAudio.__init__(self, *args, **kwargs) self.ext = u'mp3'