add video title command
This commit is contained in:
parent
da612c58c4
commit
4d82163b41
6 changed files with 80 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Christophe Benz
|
||||
Copyright(C) 2010 Christophe Benz
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,9 +21,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
import re
|
||||
|
||||
from weboob.tools.browser import Browser
|
||||
from weboob.tools.parser import LxmlHtmlParser
|
||||
|
||||
from .pages import VideoPage
|
||||
|
||||
class YoutubeBrowser(Browser):
|
||||
regex = re.compile(r'&t=([^ ,&]*)')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['parser'] = LxmlHtmlParser
|
||||
self.PAGES = {r'http://.*\.youtube\.com/watch\?v=(.+)': VideoPage}
|
||||
Browser.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_video_title(self, page_url):
|
||||
self.location(page_url)
|
||||
return self.page.title
|
||||
|
||||
def get_video_url(self, page_url):
|
||||
result = self.openurl(page_url).read()
|
||||
for _signature in re.finditer(self.regex, result):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue