[senscritique] remove id lists

This commit is contained in:
Bezleputh 2015-02-24 15:42:27 +01:00 committed by Romain Bignon
commit d2fa9242ea
3 changed files with 48 additions and 82 deletions

View file

@ -19,7 +19,7 @@
from weboob.browser import PagesBrowser, URL
from weboob.browser.profiles import Firefox
from .pages import AjaxPage, EventPage, JsonResumePage
from .pages import AjaxPage, EventPage, JsonResumePage, SettingsPage
import re
from lxml.etree import XMLSyntaxError
@ -50,13 +50,14 @@ class SenscritiqueBrowser(PagesBrowser):
})
ENCODING = 'utf-8'
CHANNELS = None
BASEURL = 'http://www.senscritique.com'
program_page = URL('/sc/tv_guides')
ajax_page = URL('/sc/tv_guides/gridContent.ajax', AjaxPage)
event_page = URL('/film/(?P<_id>.*)', EventPage)
json_page = URL('/sc/products/storyline/(?P<_id>.*).json', JsonResumePage)
setting_page = URL('/sc/tv_guides/settings.ajax', SettingsPage)
LIMIT = 25 # number of results returned for each ajax call (defined in the website).
@ -68,6 +69,17 @@ class SenscritiqueBrowser(PagesBrowser):
'limit': '%d' % LIMIT,
}
def get_channels(self):
if not self.CHANNELS:
self.CHANNELS = list(self.setting_page.go().get_channels())
return self.CHANNELS
def get_selected_channels(self, package, general=False, cinema=False):
for channel in self.get_channels():
if (package == 0 or package in channel._networks) and\
((general and channel._thema in ('1', '2')) or (cinema and channel._thema == '3')):
yield channel.id
def set_package_settings(self, package, channels):
url = 'http://www.senscritique.com/sc/tv_guides/saveSettings.json'
# do not use a dict because there are several same keys