support URLs and IDs with '-' in
This commit is contained in:
parent
eedb2a7b55
commit
31863d3171
4 changed files with 4 additions and 4 deletions
|
|
@ -46,7 +46,7 @@ class YoutubeBackend(BaseBackend, ICapVideoProvider):
|
||||||
def need_url(func):
|
def need_url(func):
|
||||||
def inner(self, *args, **kwargs):
|
def inner(self, *args, **kwargs):
|
||||||
url = args[0]
|
url = args[0]
|
||||||
if (u'youtube.com' not in url) and not re.match('^\w+$', url):
|
if (u'youtube.com' not in url) and not re.match('^[\w-]+$', url):
|
||||||
return None
|
return None
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
return inner
|
return inner
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class YoutubeBrowser(BaseBrowser):
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
||||||
def get_video(self, _id):
|
def get_video(self, _id):
|
||||||
if re.match('^\w+$', _id):
|
if re.match('^[\w-]+$', _id):
|
||||||
url = 'http://www.youtube.com/watch?v=%s' % _id
|
url = 'http://www.youtube.com/watch?v=%s' % _id
|
||||||
else:
|
else:
|
||||||
url = _id
|
url = _id
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.video import Video
|
from weboob.capabilities.video import Video
|
||||||
|
|
||||||
class ResultsPage(BasePage):
|
class ResultsPage(BasePage):
|
||||||
WATCH_RE = re.compile('/watch\?v=(\w+)')
|
WATCH_RE = re.compile('/watch\?v=([\w-]+)')
|
||||||
def iter_videos(self):
|
def iter_videos(self):
|
||||||
for div in self.document.getroot().cssselect("div[class^=video-entry]"):
|
for div in self.document.getroot().cssselect("div[class^=video-entry]"):
|
||||||
a = div.find('a')
|
a = div.find('a')
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.video import Video
|
from weboob.capabilities.video import Video
|
||||||
|
|
||||||
class VideoPage(BasePage):
|
class VideoPage(BasePage):
|
||||||
URL_REGEX = re.compile(r"https?://[w\.]*youtube.com/watch\?v=(\w+)")
|
URL_REGEX = re.compile(r"https?://[w\.]*youtube.com/watch\?v=([\w-]+)")
|
||||||
VIDEO_SIGNATURE_REGEX = re.compile(r'&t=([^ ,&]*)')
|
VIDEO_SIGNATURE_REGEX = re.compile(r'&t=([^ ,&]*)')
|
||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue