fix authenticate and retrieve of video url (closes #880)
This commit is contained in:
parent
8c9409930b
commit
12a11d98b7
2 changed files with 49 additions and 23 deletions
|
|
@ -37,27 +37,29 @@ class NolifeTVBrowser(BaseBrowser):
|
||||||
PAGES = {r'http://online.nolife-tv.com/index.php\??': IndexPage,
|
PAGES = {r'http://online.nolife-tv.com/index.php\??': IndexPage,
|
||||||
r'http://online.nolife-tv.com/': IndexPage,
|
r'http://online.nolife-tv.com/': IndexPage,
|
||||||
r'http://online.nolife-tv.com/do.php': IndexPage,
|
r'http://online.nolife-tv.com/do.php': IndexPage,
|
||||||
r'http://online.nolife-tv.com/emission-(?P<id>.+)/?.*': VideoPage}
|
r'http://online.nolife-tv.com/emission-(?P<id>[^/]+)/?.*': VideoPage}
|
||||||
|
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
if self.password is None:
|
if self.password is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
login = self.page.document.getroot().cssselect('div#form_login')
|
if not self.page:
|
||||||
return len(login) == 0
|
return False
|
||||||
|
|
||||||
|
l = self.page.document.xpath('//form[@name="login"]')
|
||||||
|
return len(l) == 0
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
if self.password is None:
|
if self.password is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
params = {'cookieuser': 1,
|
params = {'cookieuser': 1,
|
||||||
'do': 'login',
|
'login': 1,
|
||||||
'securitytoken': 'guest',
|
'username': self.username,
|
||||||
'vb_login_username': self.username,
|
'password': self.password,
|
||||||
'vb_login_password': self.password,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.readurl('http://forum.nolife-tv.com/login.php?do=login', urllib.urlencode(params))
|
self.readurl('http://online.nolife-tv.com/login', urllib.urlencode(params))
|
||||||
|
|
||||||
self.location('/', no_login=True)
|
self.location('/', no_login=True)
|
||||||
|
|
||||||
|
|
@ -82,6 +84,7 @@ class NolifeTVBrowser(BaseBrowser):
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
||||||
def latest_videos(self):
|
def latest_videos(self):
|
||||||
self.home()
|
self.location('/do.php', 'a=em')
|
||||||
|
|
||||||
assert self.is_on_page(IndexPage)
|
assert self.is_on_page(IndexPage)
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from hashlib import md5
|
||||||
|
import time
|
||||||
from dateutil.parser import parse as parse_dt
|
from dateutil.parser import parse as parse_dt
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
@ -51,14 +53,24 @@ class VideoPage(BasePage):
|
||||||
link = div.find('a').attrib['href']
|
link = div.find('a').attrib['href']
|
||||||
raise ForbiddenVideo('Video is only available here: %s' % link)
|
raise ForbiddenVideo('Video is only available here: %s' % link)
|
||||||
|
|
||||||
div = self.parser.select(self.document.getroot(), 'div#informations_video', 1)
|
meta = self.parser.select(self.document.getroot(), 'meta[property="og:title"]', 1)
|
||||||
video.title = self.parser.select(div, 'div#ligne_titre_big', 1).text
|
|
||||||
try:
|
try:
|
||||||
video.description = self.parser.select(div, 'div#ligne_titre_small', 1).text
|
video.title = unicode(meta.attrib['content'])
|
||||||
|
except BrokenPageError:
|
||||||
|
video.title = NotAvailable
|
||||||
|
|
||||||
|
meta = self.parser.select(self.document.getroot(), 'meta[property="og:description"]', 1)
|
||||||
|
try:
|
||||||
|
video.description = unicode(meta.attrib['content'])
|
||||||
except BrokenPageError:
|
except BrokenPageError:
|
||||||
video.description = NotAvailable
|
video.description = NotAvailable
|
||||||
|
|
||||||
video.thumbnail = Thumbnail(self.parser.select(div, 'div#icone_video img', 1).attrib['src'])
|
meta = self.parser.select(self.document.getroot(), 'meta[property="og:image"]', 1)
|
||||||
|
try:
|
||||||
|
video.thumbnail = Thumbnail(unicode(meta.attrib['content']))
|
||||||
|
except BrokenPageError:
|
||||||
|
video.thumbnail = NotAvailable
|
||||||
|
|
||||||
try:
|
try:
|
||||||
video.date = parse_dt(self.parser.select(div, 'div#infos_complementaires', 1).find('p').text.strip())
|
video.date = parse_dt(self.parser.select(div, 'div#infos_complementaires', 1).find('p').text.strip())
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -69,20 +81,31 @@ class VideoPage(BasePage):
|
||||||
video.rating_max = NotAvailable
|
video.rating_max = NotAvailable
|
||||||
|
|
||||||
if not video.url:
|
if not video.url:
|
||||||
r = self.browser.request_class('http://online.nolife-tv.com/_newplayer/api/api_player.php',
|
skey, timestamp = self.genkey()
|
||||||
'skey=9fJhXtl%5D%7CFR%3FN%7D%5B%3A%5Fd%22%5F&connect=1&a=US',
|
self.browser.readurl('http://online.nolife-tv.com/_nlfplayer/api/api_player.php',
|
||||||
{'Referer': 'http://online.nolife-tv.com/_newplayer/nolifeplayer_flash10.swf?idvideo=%s&autostart=0' % _id})
|
'skey=%s&a=MD5×tamp=%s' % (skey, timestamp))
|
||||||
self.browser.openurl(r)
|
|
||||||
r = self.browser.request_class('http://online.nolife-tv.com/_newplayer/api/api_player.php',
|
skey, timestamp = self.genkey()
|
||||||
'skey=9fJhXtl%5D%7CFR%3FN%7D%5B%3A%5Fd%22%5F&a=UEM%7CSEM&quality=0&id%5Fnlshow=' + _id,
|
self.browser.readurl('http://online.nolife-tv.com/_nlfplayer/api/api_player.php',
|
||||||
{'Referer': 'http://online.nolife-tv.com/_newplayer/nolifeplayer_flash10.swf?idvideo=%s&autostart=0' % _id})
|
'a=EML&skey=%s&id%%5Fnlshow=%s×tamp=%s' % (skey, _id, timestamp))
|
||||||
data = self.browser.readurl(r)
|
|
||||||
|
skey, timestamp = self.genkey()
|
||||||
|
data = self.browser.readurl('http://online.nolife-tv.com/_nlfplayer/api/api_player.php',
|
||||||
|
'quality=0&a=UEM%%7CSEM%%7CMEM%%7CCH%%7CSWQ&skey=%s&id%%5Fnlshow=%s×tamp=%s' % (skey, _id, timestamp))
|
||||||
|
|
||||||
values = dict([urllib.splitvalue(s) for s in data.split('&')])
|
values = dict([urllib.splitvalue(s) for s in data.split('&')])
|
||||||
|
|
||||||
if not 'url' in values:
|
if not 'url' in values:
|
||||||
raise ForbiddenVideo(values.get('message', 'Not available').decode('iso-8859-15'))
|
raise ForbiddenVideo(values.get('message', 'Not available').decode('iso-8859-15'))
|
||||||
video.url = values['url']
|
video.url = unicode(values['url'])
|
||||||
|
|
||||||
video.set_empty_fields(NotAvailable)
|
video.set_empty_fields(NotAvailable)
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
|
||||||
|
SALT = 'a53be1853770f0ebe0311d6993c7bcbe'
|
||||||
|
def genkey(self):
|
||||||
|
# This website is really useful to get info: http://www.showmycode.com/
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
skey = md5(md5(timestamp).hexdigest() + self.SALT).hexdigest()
|
||||||
|
return skey, timestamp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue