def resolve(self, url): try: url = client.request(urlparse.urljoin(self.base_link, url), output='geturl') if self.base_link not in url: return url header = {'User-Agent': self.user_agent, 'Accept': 'text/html'} self.__login() cookie = self.cookie try: res = client.request(url, headers=header, cookie=cookie, redirect=False, output='geturl') if self.base_link not in res: url = res else: control.infoDialog(control.lang(32572).encode('utf-8'), sound=True, icon='WARNING') except: return return url except: return
def cache_version_check(): if _find_cache_version(): cache_clear() cache_clear_meta() cache_clear_providers() control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
def manager(name, imdb, tvdb, content): try: post = { "movies": [{ "ids": { "imdb": imdb } }] } if content == 'movie' else { "shows": [{ "ids": { "tvdb": tvdb } }] } items = [(control.lang(32516).encode('utf-8'), '/sync/collection')] items += [(control.lang(32517).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(32519).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(32520).encode('utf-8'), '/users/me/lists/%s/items')] result = getTraktAsJson('/users/me/lists') lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i // 2] for i in range(len(lists) * 2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(32515).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = __getTrakt('/users/me/lists', post={ "name": new, "privacy": "private" })[0] try: slug = utils.json_loads_as_str(result)['ids']['slug'] except: return control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon='ERROR') result = __getTrakt(items[select][1] % slug, post=post)[0] else: result = __getTrakt(items[select][1], post=post)[0] icon = control.infoLabel( 'ListItem.Icon') if not result == None else 'ERROR' control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon=icon) except: return