-retrait de ICapCollection -correction du fonctionnement de get_video pour gérer les id à la place d'objets video
Signed-off-by: Bezleputh <carton_ben@yahoo.fr>
This commit is contained in:
parent
57db9bbebb
commit
d2724577c8
2 changed files with 14 additions and 12 deletions
|
|
@ -20,12 +20,11 @@
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
from weboob.capabilities.video import ICapVideo, BaseVideo
|
from weboob.capabilities.video import ICapVideo, BaseVideo
|
||||||
from weboob.capabilities.collection import ICapCollection
|
|
||||||
from .browser import GroovesharkBrowser
|
from .browser import GroovesharkBrowser
|
||||||
|
|
||||||
__all__ = ['GroovesharkBackend']
|
__all__ = ['GroovesharkBackend']
|
||||||
|
|
||||||
class GroovesharkBackend(BaseBackend, ICapVideo, ICapCollection):
|
class GroovesharkBackend(BaseBackend, ICapVideo):
|
||||||
NAME = 'grooveshark'
|
NAME = 'grooveshark'
|
||||||
DESCRIPTION = u'grooveshark website'
|
DESCRIPTION = u'grooveshark website'
|
||||||
MAINTAINER = u'Bezleputh'
|
MAINTAINER = u'Bezleputh'
|
||||||
|
|
@ -48,8 +47,8 @@ class GroovesharkBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
for video in self.browser.search_videos(pattern, max_results):
|
for video in self.browser.search_videos(pattern, max_results):
|
||||||
yield video
|
yield video
|
||||||
|
|
||||||
def get_video(self, video):
|
def get_video(self, _id):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.fill_stream_list(video)
|
return self.browser.get_video_from_song_id(_id)
|
||||||
|
|
||||||
OBJECTS = {BaseVideo: fill_video}
|
OBJECTS = {BaseVideo: fill_video}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import string
|
||||||
import random
|
import random
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['GroovesharkBrowser']
|
__all__ = ['GroovesharkBrowser']
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,6 +59,8 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
GROOVESHARK_CONSTANTS = ('mobileshark', '20120830', 'gooeyFlubber')
|
GROOVESHARK_CONSTANTS = ('mobileshark', '20120830', 'gooeyFlubber')
|
||||||
COMMUNICATION_TOKEN = None
|
COMMUNICATION_TOKEN = None
|
||||||
|
|
||||||
|
VIDEOS_FROM_SONG_RESULTS = None
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
self.get_communication_token()
|
self.get_communication_token()
|
||||||
|
|
||||||
|
|
@ -81,8 +82,7 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
return songs
|
return songs
|
||||||
|
|
||||||
def create_video_from_songs_result(self, songs, max_results):
|
def create_video_from_songs_result(self, songs, max_results):
|
||||||
videos = []
|
self.VIDEOS_FROM_SONG_RESULTS = []
|
||||||
|
|
||||||
if max_results:
|
if max_results:
|
||||||
songs = songs[0:max_results]
|
songs = songs[0:max_results]
|
||||||
|
|
||||||
|
|
@ -98,8 +98,8 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
video.date = datetime.date(year=int(song['Year']), month=1, day=1)
|
video.date = datetime.date(year=int(song['Year']), month=1, day=1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
video.date = NotAvailable
|
video.date = NotAvailable
|
||||||
videos.append(video)
|
self.VIDEOS_FROM_SONG_RESULTS.append(video)
|
||||||
return videos
|
return self.VIDEOS_FROM_SONG_RESULTS
|
||||||
|
|
||||||
def create_video_from_playlist_result(self, playlists):
|
def create_video_from_playlist_result(self, playlists):
|
||||||
videos = []
|
videos = []
|
||||||
|
|
@ -132,9 +132,12 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
rnd = (''.join(random.choice(string.hexdigits) for x in range(6)))
|
rnd = (''.join(random.choice(string.hexdigits) for x in range(6)))
|
||||||
return rnd + hashlib.sha1('%s:%s:%s:%s' % (method, self.COMMUNICATION_TOKEN, self.GROOVESHARK_CONSTANTS[2], rnd)).hexdigest()
|
return rnd + hashlib.sha1('%s:%s:%s:%s' % (method, self.COMMUNICATION_TOKEN, self.GROOVESHARK_CONSTANTS[2], rnd)).hexdigest()
|
||||||
|
|
||||||
def fill_stream_list(self, video):
|
def get_video_from_song_id(self, song_id):
|
||||||
if isinstance(video, BaseVideo):
|
if self.VIDEOS_FROM_SONG_RESULTS:
|
||||||
video.url = self.get_stream_url_from_song_id(video.id)
|
for video in self.VIDEOS_FROM_SONG_RESULTS:
|
||||||
|
if video.id == song_id:
|
||||||
|
video.url = self.get_stream_url_from_song_id(song_id)
|
||||||
|
return video
|
||||||
|
|
||||||
def get_stream_url_from_song_id(self, song_id):
|
def get_stream_url_from_song_id(self, song_id):
|
||||||
method = 'getStreamKeyFromSongIDEx'
|
method = 'getStreamKeyFromSongIDEx'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue