def __init__( self ): viewtype.__init__( self ) self.args = Info() self.watched = getWatched() if self.args.isempty(): self._add_directory_root() elif self.args.GetCarrousel: self._add_directory_carrousel( self.args.GetCarrousel ) elif self.args.PID: start_player = True startoffset = None if self.args.ChapterStartTimes: try: chapters = [ "00:00:00" ] + self.args.ChapterStartTimes.split( "," ) selected = xbmcgui.Dialog().select( "Chapters Start Times", [ "%s %i (%s)" % ( LangXBMC( 21396 ), i+1, c ) for i, c in enumerate( chapters ) ] ) if selected != -1: h, m, s = chapters[ selected ].split( ":" ) startoffset = str( eval( "(%s*60*60)+(%s*60)+%s" % ( h, m, s ) ) ) else: start_player = False except: print_exc() if start_player: import TouTvPlayer as player try: player.playVideo( self.args.PID, startoffset=startoffset ) except: print_exc() elif self.args.emissionId: self._add_directory_episodes( self.args.emissionId ) elif self.args.GetPageGenre: self._add_directory_genre( self.args.GetPageGenre ) elif self.args.webbrowser: import webbrowser webbrowser.open( unquote_plus( self.args.webbrowser ) ) elif self.args.addtofavourites or self.args.removefromfavourites: #add to my favourites favourite = unquote_plus( self.args.addtofavourites or self.args.removefromfavourites ) if os.path.exists( FAVOURITES_XML ): favourites = open( FAVOURITES_XML ).read() else: favourites = '<favourites>\n</favourites>\n' if self.args.removefromfavourites or favourite not in favourites: if self.args.removefromfavourites: favourites = favourites.replace( ' %s\n' % favourite, '' ) refresh = True else: favourites = favourites.replace( '</favourites>', ' %s\n</favourites>' % favourite ) refresh = False file( FAVOURITES_XML, "w" ).write( favourites ) if refresh: if favourites == '<favourites>\n</favourites>\n': try: os.remove( FAVOURITES_XML ) except: pass xbmc.executebuiltin( 'Action(ParentDir)' ) xbmc.sleep( 1000 ) xbmc.executebuiltin( 'Container.Refresh' ) elif self.args.setwatched or self.args.setunwatched: strwatched = self.args.setwatched or self.args.setunwatched setWatched( strwatched, bool( self.args.setunwatched ), self.args.all ) elif self.args.category == "genres": self._add_directory_genres() elif self.args.category in [ "outdated", "repertoire" ]: self._add_directory_emissions( self.args.category == "outdated" ) elif self.args.category == "collection": self._add_directory_collection() elif self.args.category == "recherche": self._add_directory_search() elif self.args.category == "myfavourites": self._add_directory_favourites() elif self.args.category == "countries": self._add_directory_countries() else: #show home section = { "favoris": "EpisodesFavoris", #<type 'list'> "adecouvrir": "SelectionADecouvrir", #<type 'dict'> "carrousel": "SelectionCarrousel", #<type 'dict'> "plusrecents": "SelectionPlusRecents", #<type 'dict'> }.get( self.args.category ) if section: self._add_directory_accueil( section ) else: self._end_of_directory( False )
def __init__(self): viewtype.__init__(self) self.args = Info() self.watched = getWatched() if self.args.isempty(): self._add_directory_root() elif self.args.GetCarrousel: self._add_directory_carrousel(self.args.GetCarrousel) elif self.args.PID: start_player = True startoffset = None if self.args.ChapterStartTimes: try: chapters = ["00:00:00" ] + self.args.ChapterStartTimes.split(",") selected = xbmcgui.Dialog().select( "Chapters Start Times", [ "%s %i (%s)" % (LangXBMC(21396), i + 1, c) for i, c in enumerate(chapters) ]) if selected != -1: h, m, s = chapters[selected].split(":") startoffset = str( eval("(%s*60*60)+(%s*60)+%s" % (h, m, s))) else: start_player = False except: print_exc() if start_player: import TouTvPlayer as player try: player.playVideo(self.args.PID, startoffset=startoffset) except: print_exc() elif self.args.emissionId: self._add_directory_episodes(self.args.emissionId) elif self.args.GetPageGenre: self._add_directory_genre(self.args.GetPageGenre) elif self.args.webbrowser: import webbrowser webbrowser.open(unquote_plus(self.args.webbrowser)) elif self.args.addtofavourites or self.args.removefromfavourites: #add to my favourites favourite = unquote_plus(self.args.addtofavourites or self.args.removefromfavourites) if os.path.exists(FAVOURITES_XML): favourites = open(FAVOURITES_XML).read() else: favourites = '<favourites>\n</favourites>\n' if self.args.removefromfavourites or favourite not in favourites: if self.args.removefromfavourites: favourites = favourites.replace(' %s\n' % favourite, '') refresh = True else: favourites = favourites.replace( '</favourites>', ' %s\n</favourites>' % favourite) refresh = False file(FAVOURITES_XML, "w").write(favourites) if refresh: if favourites == '<favourites>\n</favourites>\n': try: os.remove(FAVOURITES_XML) except: pass xbmc.executebuiltin('Action(ParentDir)') xbmc.sleep(1000) xbmc.executebuiltin('Container.Refresh') elif self.args.setwatched or self.args.setunwatched: strwatched = self.args.setwatched or self.args.setunwatched setWatched(strwatched, bool(self.args.setunwatched), self.args.all) elif self.args.category == "genres": self._add_directory_genres() elif self.args.category in ["outdated", "repertoire"]: self._add_directory_emissions(self.args.category == "outdated") elif self.args.category == "collection": self._add_directory_collection() elif self.args.category == "recherche": self._add_directory_search() elif self.args.category == "myfavourites": self._add_directory_favourites() elif self.args.category == "countries": self._add_directory_countries() else: #show home section = { "favoris": "EpisodesFavoris", #<type 'list'> "adecouvrir": "SelectionADecouvrir", #<type 'dict'> "carrousel": "SelectionCarrousel", #<type 'dict'> "plusrecents": "SelectionPlusRecents", #<type 'dict'> }.get(self.args.category) if section: self._add_directory_accueil(section) else: self._end_of_directory(False)
def __init__(self): viewtype.__init__(self) self.args = Info() self.watched = getWatched() if not xbmcgui.Window(10000).getProperty("plugin.video.illicoweb_running") == "True": addon_log("** Service not running **") xbmc.executescript(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), "service.py")) if self.args.isempty(): self._login() self._add_directory_root() elif self.args.setwatched or self.args.setunwatched: strwatched = self.args.setwatched or self.args.setunwatched if self.args.all: url, label = strwatched.split("*") seasonNo = url[url.rfind(",") + 1 :] url = "/" + url[: url.rfind(",")] data = self._getShowJSON(url) seasons = simplejson.loads(data)["body"]["SeasonHierarchy"]["seasons"] # [body][SeasonHierarchy][seasons] seasons for i in seasons: # addon_log(i['seasonNo'] + ' ==? ' + seasonNo) if str(i["seasonNo"]) == seasonNo: for ep in i["episodes"]: setWatched(ep["orderURI"] + "*" + ep["title"], bool(self.args.setunwatched), False) # [body][main] seasons i = simplejson.loads(data)["body"]["main"] if str(i["seasonNo"]) == seasonNo: for ep in i["episodes"]: setWatched(ep["orderURI"] + "*" + ep["title"], bool(self.args.setunwatched), False) # xbmc.executebuiltin( 'Container.Refresh' ) else: setWatched(strwatched, bool(self.args.setunwatched)) elif self.args.addtofavourites or self.args.removefromfavourites: # turn dict back into url, decode it and format it in xml f = unquote_plus(self.args.addtofavourites or self.args.removefromfavourites) f = parse_qs(urlparse("?" + f.replace(", ", "&").replace('"', "%22")).query) favourite = '<favourite label="%s" category="%s" url="%s" />' % ( unquote_plus(f["label"][0]), f["category"][0], f["url"][0], ) if os.path.exists(FAVOURITES_XML): favourites = open(FAVOURITES_XML).read() else: favourites = "<favourites>\n</favourites>\n" if self.args.removefromfavourites or favourite not in favourites: if self.args.removefromfavourites: addon_log("Removing %s from favourites" % favourite) favourites = favourites.replace(" %s\n" % favourite, "") refresh = True else: favourites = favourites.replace("</favourites>", " %s\n</favourites>" % (favourite)) refresh = False file(FAVOURITES_XML, "w").write(favourites) if refresh: if favourites == "<favourites>\n</favourites>\n": try: os.remove(FAVOURITES_XML) except: pass xbmc.executebuiltin("Action(ParentDir)") xbmc.sleep(1000) xbmc.executebuiltin("Container.Refresh") elif self.args.favoris: self._add_directory_favourites() elif self.args.live: self._playLive(unquote_plus(self.args.live).replace(" ", "+")) elif self.args.episode: self._checkCookies() self._playEpisode(unquote_plus(self.args.episode).replace(" ", "+")) elif self.args.channel: url = unquote_plus(self.args.channel).replace(" ", "+") shows, fanart, livelist = self._getShows(url) listitems = [] if "channels" in shows: for channel in shows["channels"]: self._addChannelToGalaxie(channel, listitems, fanart) else: for i in shows: if "submenus" in i: for show in i["submenus"]: self._addShowToChannel(show, listitems, fanart) else: self._addShowToChannel(i, listitems, fanart) if listitems: # Sort list by ListItem Label listitems = self.natural_sort(listitems, False) if len(listitems) == 0: live = livelist[0][0] self._playLive(live[live.find('"') :].replace('"', "")) return listitems = livelist + listitems addon_log("Adding Shows to Channel") OK = self._add_directory_items(listitems) self._set_content(OK, "episodes", False) elif self.args.show: OK = False listitems = self._getSeasons(unquote_plus(self.args.show).replace(" ", "+")) if listitems: from operator import itemgetter listitems = self.natural_sort(listitems, True) addon_log("Adding Seasons to Show") OK = self._add_directory_items(listitems) self._set_content(OK, "episodes", False) elif self.args.season: url = unquote_plus(self.args.season).replace(" ", "+") season = url[url.rfind(",") + 1 :] url = url[: url.rfind(",")] data = self._getShowJSON(url) self._addEpisodesToSeason(data, season)