Use mobile.nolife-tv.com instead of online.nolife-tv.com. Add theme/type entries. These changes are inspired by XBMC NolifeTV plugin from Julien Gormotte: julien@gormotte.info videoob> ls ~ (theme) Par theme (nolifetv) ~ (type) Par type (nolifetv) ~ (latest) Latest NolifeTV videos (nolifetv) videoob> cd theme videoob:/theme> ls ~ (Actualités) Actualités (nolifetv) ~ (Fictions) Fictions (nolifetv) ~ (Musique) Musique (nolifetv) ~ (Nolife) Nolife (nolifetv) ~ (Culture & Style) Culture & Style (nolifetv) ~ (Jeu vidéo) Jeu vidéo (nolifetv) ~ (Sélection pour découvrir Nolife) Sélection pour découvrir Nolife (nolifetv) ~ (Japon) Japon (nolifetv) videoob:/theme> cd Japon videoob:/theme/Japon> ls ~ (77) Japan in Motion (nolifetv) ~ (68) J-Top (Speed run) (nolifetv) ~ (84) Nochan (nolifetv) ~ (49) OTO (nolifetv) ~ (100) toco toco (nolifetv) ~ (112) Nihongo ga dekimasu ka (nolifetv) ~ (57) Tôkyô Café (nolifetv) videoob:/theme/Japon> cd 57 Hint: There are more results available for nolifetv (use option -n or count command) 1 — Tôkyô Café - 239 - La statue Gundam à Odaiba (nolifetv) 2 — Tôkyô Café - 238 - UNCHAIN (nolifetv) 3 — Tôkyô Café - 237 - The End au Théâtre du Châtelet (nolifetv) 4 — Tôkyô Café - 236 - Scéance photo à Asobi Station dans le quartier de Harajuku avec YANO Anna (nolifetv) 5 — Tôkyô Café - 235 - Le TGS 2013 vu par Suzuka (nolifetv) 6 — Tôkyô Café - 234 - Street Live de Itowokashi à Tôkyô (chanson en intégralité) (nolifetv) 7 — Tôkyô Café - 234 - Street Live de Itowokashi à Tôkyô (nolifetv) 8 — Tôkyô Café - 233 - Tsume Fan Day (nolifetv) 9 — Tôkyô Café - 232 - Puzzle & Dragons (nolifetv) 10 — Tôkyô Café - 231 - Japan Expo 2013 (nolifetv) Signed-off-by: Clément Calmels <cboulte@gmail.com> Signed-off-by: Romain Bignon <romain@symlink.me>
107 lines
3.5 KiB
Python
107 lines
3.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright(C) 2011 Romain Bignon
|
|
#
|
|
# This file is part of weboob.
|
|
#
|
|
# weboob is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# weboob is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
|
|
|
import urllib
|
|
|
|
from weboob.tools.browser.decorators import id2url
|
|
from .video import NolifeTVVideo
|
|
from .pages import VideoPage, VideoListPage, FamilyPage, AboPage, LoginPage, HomePage
|
|
|
|
__all__ = ['NolifeTVBrowser']
|
|
|
|
class NolifeTVBrowser(BaseBrowser):
|
|
USER_AGENT = BaseBrowser.USER_AGENTS['desktop_firefox']
|
|
DOMAIN = 'mobile.nolife-tv.com'
|
|
PROTOCOL = 'http'
|
|
PAGES = { r'http://mobile.nolife-tv.com/online/familles-\w+/': FamilyPage,
|
|
r'http://mobile.nolife-tv.com/online/emission-(?P<id>\d+)/': VideoPage,
|
|
'http://mobile.nolife-tv.com/do.php': VideoListPage,
|
|
'http://mobile.nolife-tv.com/online/': VideoListPage,
|
|
'http://mobile.nolife-tv.com/abonnement/': AboPage,
|
|
'http://mobile.nolife-tv.com/login': LoginPage,
|
|
'http://mobile.nolife-tv.com/': HomePage,
|
|
}
|
|
AVAILABLE_VIDEOS = ['[Gratuit]']
|
|
|
|
def is_logged(self):
|
|
return not self.is_on_page(HomePage) or self.page.is_logged()
|
|
|
|
def login(self):
|
|
if not self.is_on_page(LoginPage):
|
|
self.location('/login', no_login=True)
|
|
|
|
self.page.login(self.username, self.password)
|
|
|
|
if self.is_on_page(LoginPage):
|
|
raise BrowserIncorrectPassword()
|
|
|
|
self.location('/abonnement/', no_login=True)
|
|
assert self.is_on_page(AboPage)
|
|
|
|
self.AVAILABLE_VIDEOS = self.page.get_available_videos()
|
|
|
|
@id2url(NolifeTVVideo.id2url)
|
|
def get_video(self, url, video=None):
|
|
self.location(url)
|
|
assert self.is_on_page(VideoPage)
|
|
|
|
return self.page.get_video(video)
|
|
|
|
def iter_family(self, type, sub):
|
|
self.location('/online/familles-%s/' % type)
|
|
assert self.is_on_page(FamilyPage)
|
|
|
|
return self.page.iter_family(sub)
|
|
|
|
def iter_category(self, type):
|
|
self.location('/online/familles-%s/' % type)
|
|
assert self.is_on_page(FamilyPage)
|
|
|
|
return self.page.iter_category()
|
|
|
|
def iter_video(self, family):
|
|
data = { 'a': 'ge',
|
|
'famille': family,
|
|
'emissions': 0 }
|
|
|
|
while True:
|
|
self.location('/do.php', urllib.urlencode(data))
|
|
assert self.is_on_page(VideoListPage)
|
|
|
|
if self.page.is_list_empty():
|
|
break
|
|
|
|
for vid in self.page.iter_video(self.AVAILABLE_VIDEOS):
|
|
yield vid
|
|
data['emissions'] = data['emissions'] + 1
|
|
|
|
def get_latest(self):
|
|
return self.iter_video(0)
|
|
|
|
def search_videos(self, pattern):
|
|
data = { 'search': pattern,
|
|
'submit': 'Rechercher' }
|
|
self.location('/online/', urllib.urlencode(data))
|
|
assert self.is_on_page(VideoListPage)
|
|
|
|
for vid in self.page.iter_video(self.AVAILABLE_VIDEOS):
|
|
yield vid
|