bugfix #264: use gdata API for youtube
This commit is contained in:
parent
eedb2a7b55
commit
ce83fb011f
5 changed files with 25 additions and 100 deletions
|
|
@ -19,35 +19,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
"""
|
||||
|
||||
import urllib
|
||||
import re
|
||||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
|
||||
from .pages import VideoPage, ResultsPage
|
||||
from .pages import VideoPage
|
||||
|
||||
__all__ = ['YoutubeBrowser']
|
||||
|
||||
class YoutubeBrowser(BaseBrowser):
|
||||
PAGES = {'.*youtube\.com/watch\?v=(.+)': VideoPage,
|
||||
'.*youtube\.com/results\?.*': ResultsPage,
|
||||
}
|
||||
|
||||
def iter_search_results(self, pattern, sortby):
|
||||
if not pattern:
|
||||
self.home()
|
||||
else:
|
||||
if sortby:
|
||||
sortby = '&search_sort=%s' % sortby
|
||||
self.location('http://www.youtube.com/results?search_type=videos&search_query=%s%s' % (urllib.quote_plus(pattern), sortby))
|
||||
|
||||
assert self.is_on_page(ResultsPage)
|
||||
return self.page.iter_videos()
|
||||
def id2url(self, _id):
|
||||
return _id if 'youtube.com' in _id else 'http://www.youtube.com/watch?v=%s' % _id
|
||||
|
||||
def get_video(self, _id):
|
||||
if re.match('^\w+$', _id):
|
||||
url = 'http://www.youtube.com/watch?v=%s' % _id
|
||||
else:
|
||||
url = _id
|
||||
|
||||
self.location(url)
|
||||
self.location(self.id2url(_id))
|
||||
return self.page.video
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue