def onInit(self): p = xbmcgui.DialogProgress() p.create(_(32000), _(32001)) # 'Transmission', 'Connecting to Transmission' try: self.transmission = common.get_rpc_client() except: p.close() self.close() (type, e, traceback) = sys.exc_info() message = _(32900) # Unexpected error if type is transmissionrpc.TransmissionError: if e.original: if e.original.code is 401: message = _(32902) # Invalid auth else: message = _(32901) # Unable to connect if xbmcgui.Dialog().yesno(_(32002), message, _(32003)): __settings__.openSettings() elif type is ValueError: # In python 2.4, urllib2.HTTPDigestAuthHandler will barf up a lung # if auth fails and the server wants non-digest authentication message = _(32902) # Invalid auth if xbmcgui.Dialog().yesno(_(32002), message, _(32003)): __settings__.openSettings() else: message = _(32900) # Unexpected error xbmcgui.Dialog().ok(_(32002), message) return False self.updateTorrents() p.close() self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents) self.timer.start()
def refreshSettings(self): settings = common.get_settings() if settings != self.prev_settings: self.active = (settings['stop_all_on_playback'] == 'true') try: self.transmission = common.get_rpc_client() except: self.transmission = None self.prev_settings = settings
def refreshSettings(self): settings = common.get_settings() if settings != self.prev_settings: self.mode = settings['action_on_playback'] self.keep_seeding = settings['seeding_torrents'] self.show_notifications = settings['show_notifications'] self.seconds = int(settings['seconds_playback_finished'])*1000 try: self.transmission = common.get_rpc_client() except: self.transmission = None self.prev_settings = settings
def onInit(self): if not len(__settings__.getSetting('download_path')): self.close() if xbmcgui.Dialog().yesno(_(32002), _(32903), _(32003)): __settings__.openSettings() return False p = xbmcgui.DialogProgress() p.create(_(32000), _(32001)) # 'Deluge', 'Connecting to Deluge' self.deluge = common.get_rpc_client() info = self.deluge.get_info() if (not info or info['result']['connected'] is not True): xbmc.log(json.dumps(info), xbmc.LOGDEBUG) p.close() self.close() message = _(32901) # Unable to connect if xbmcgui.Dialog().yesno(_(32002), message, _(32003)): __settings__.openSettings() del p return False self.updateTorrents() p.close() del p self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents) self.timer.start()
def onClick(self, controlID): list = self.getControl(120) if (controlID == 111): # Add torrent engines = [ (_(32200), None), (_(32204), search.Kickass), (_(32208), search.EZTV), (_(32202), search.TPB), (_(32205), search.L337x), (_(32206), search.YTS), (_(32207), search.Lime), ] selected = xbmcgui.Dialog().select(_(32000), [i[0] for i in engines]) if selected < 0: return engine = engines[selected][1] if not engine: filename = xbmcgui.Dialog().input(_(32000), '', xbmcgui.INPUT_ALPHANUM) if (len(filename)): self.deluge.add_url(filename, __settings__.getSetting('download_path')) else: kb = xbmc.Keyboard(__settings__.getSetting('last_search'), engines[selected][0]) kb.doModal() if not kb.isConfirmed(): return terms = kb.getText() __settings__.setSetting('last_search', terms) p = xbmcgui.DialogProgress() p.create(_(32000), _(32290)) try: results = engine().search(terms) except: p.close() xbmcgui.Dialog().ok(_(32000), _(32292)) return p.close() del p if not results: xbmcgui.Dialog().ok(_(32000), _(32291)) return selected = xbmcgui.Dialog().select(_(32000), ['[S:%d L:%d] %s'%(t['seeds'], t['leechers'], t['name']) for t in results]) if selected < 0: return try: self.deluge.add_url(results[selected]['url'], __settings__.getSetting('download_path')) except: xbmcgui.Dialog().ok(_(32000), _(32293)) return if (controlID == 112): # Remove selected torrent item = list.getSelectedItem() if item and xbmcgui.Dialog().yesno(_(32000), 'Remove \'%s\'?'%item.getLabel()): remove_data = xbmcgui.Dialog().yesno(_(32000), 'Remove data as well?') if remove_data: self.deluge.action_simple('removedata', item.getProperty('TorrentID')) else: self.deluge.action_simple('remove', item.getProperty('TorrentID')) if (controlID == 113): # Stop selected torrent item = list.getSelectedItem() if item: self.deluge.action_simple('stop', item.getProperty('TorrentID')) if (controlID == 114): # Start selected torrent item = list.getSelectedItem() if item: self.deluge.action_simple('start', item.getProperty('TorrentID')) if (controlID == 115): # Stop all torrents for torrent in self.torrents: self.deluge.action_simple('stop', torrent['id']) if (controlID == 116): # Start all torrents for torrent in self.torrents: self.deluge.action_simple('start', torrent['id']) if (controlID == 118): # Settings button prev_settings = common.get_settings() __settings__.openSettings() p = xbmcgui.DialogProgress() p.create(_(32000), _(32001)) # 'Transmission', 'Connecting to Transmission' try: self.deluge = common.get_rpc_client() self.updateTorrents() p.close() except: p.close() xbmcgui.Dialog().ok(_(32002), _(32901)) # restore settings self.set_settings(prev_settings) try: self.deluge = common.get_rpc_client() except err: xbmcgui.Dialog().ok(_(32002), _(32901)) self.close() del p if (controlID == 120): global PLAY_REQUESTED # A torrent was chosen, show details item = list.getSelectedItem() w = TorrentInfoGUI("script-Deluge-details.xml", __settings__.getAddonInfo('path'), "Default") w.setTorrent(self.deluge, item.getProperty('TorrentID')) w.doModal() del w if PLAY_REQUESTED: PLAY_REQUESTED = False self.close() if (controlID == 117): # Exit button self.close()
def onClick(self, controlID): list = self.getControl(120) if (controlID == 111): # Add torrent engines = [ (_(32200), None), (_(32209), search.Torrent9), ] selected = xbmcgui.Dialog().select(_(32000), [i[0] for i in engines]) if selected < 0: return engine = engines[selected][1] if not engine: filename = xbmcgui.Dialog().browse(1, _(32000), 'files', '.torrent') try: f = open(filename, 'r') data = base64.b64encode(f.read()) self.transmission.add(data) except: pass else: kb = xbmc.Keyboard('', engines[selected][0]) kb.doModal() if not kb.isConfirmed(): return terms = kb.getText() p = xbmcgui.DialogProgress() p.create(_(32000), _(32290)) try: results = engine().search(terms) except: p.close() xbmcgui.Dialog().ok(_(32000), _(32292)) return p.close() if not results: xbmcgui.Dialog().ok(_(32000), _(32291)) return selected = xbmcgui.Dialog().select(_(32000), [ '[S:%d L:%d] %s' % (t['seeds'], t['leechers'], t['name']) for t in results ]) if selected < 0: return try: if (engine == search.T411): t = t411() data = t.download(results[selected]['url']) self.transmission.add(data) else: self.transmission.add_torrent(results[selected]['url']) except Exception as e: #xbmcgui.Dialog().ok("test", e.message) xbmcgui.Dialog().ok(_(32000), _(32293)) return if (controlID == 112): # Remove selected torrent item = list.getSelectedItem() if item and xbmcgui.Dialog().yesno( _(32000), 'Remove \'%s\'?' % self.torrents[int(item.getProperty('TorrentID'))].name): remove_data = xbmcgui.Dialog().yesno(_(32000), 'Remove data as well?') self.transmission.remove(int(item.getProperty('TorrentID')), remove_data) if (controlID == 113): # Stop selected torrent item = list.getSelectedItem() if item: self.transmission.stop(int(item.getProperty('TorrentID'))) if (controlID == 114): # Start selected torrent item = list.getSelectedItem() if item: self.transmission.start(int(item.getProperty('TorrentID'))) if (controlID == 115): # Stop all torrents self.transmission.stop(self.torrents.keys()) if (controlID == 116): # Start all torrents self.transmission.start(self.torrents.keys()) if (controlID == 117): # Exit button self.close() if (controlID == 118): # Settings button prev_settings = common.get_settings() __settings__.openSettings() p = xbmcgui.DialogProgress() p.create(_(32000), _(32001)) # 'Transmission', 'Connecting to Transmission' try: self.transmission = common.get_rpc_client() self.updateTorrents() p.close() except: p.close() xbmcgui.Dialog().ok(_(32002), _(32901)) # restore settings self.set_settings(prev_settings) try: self.transmission = common.get_rpc_client() except err: xbmcgui.Dialog().ok(_(32002), _(32901)) self.close() if (controlID == 120): # A torrent was chosen, show details item = list.getSelectedItem() w = TorrentInfoGUI("script-Transmission-details.xml", __settings__.getAddonInfo('path'), "Default") w.setTorrent(self.transmission, int(item.getProperty('TorrentID'))) w.doModal() del w
def onClick(self, controlID): list = self.getControl(120) if (controlID == 111): # Add torrent engines = [ (_(32200), None), (_(32202), search.TPB), (_(32203), search.Mininova), (_(32204), search.Kickass), (_(32205), search.L337x), (_(32206), search.YTS), (_(32207), search.Lime), (_(32208), search.EZTV), ] selected = xbmcgui.Dialog().select(_(32000), [i[0] for i in engines]) if selected < 0: return engine = engines[selected][1] if not engine: filename = xbmcgui.Dialog().browse(1, _(32000), 'files', '.torrent') try: f = open(filename, 'r') data = base64.b64encode(f.read()) self.transmission.add(data) except: pass else: kb = xbmc.Keyboard('', engines[selected][0]) kb.doModal() if not kb.isConfirmed(): return terms = kb.getText() p = xbmcgui.DialogProgress() p.create(_(32000), _(32290)) try: results = engine().search(terms) except: p.close() xbmcgui.Dialog().ok(_(32000), _(32292)) return p.close() if not results: xbmcgui.Dialog().ok(_(32000), _(32291)) return selected = xbmcgui.Dialog().select(_(32000), ['[S:%d L:%d] %s' % (t['seeds'], t['leechers'], t['name']) for t in results]) if selected < 0: return try: self.transmission.add_torrent(results[selected]['url']) except: xbmcgui.Dialog().ok(_(32000), _(32293)) return if (controlID == 112): # Remove selected torrent item = list.getSelectedItem() if item and xbmcgui.Dialog().yesno(_(32000), 'Remove \'%s\'?' % self.torrents[int(item.getProperty('TorrentID'))].name): remove_data = xbmcgui.Dialog().yesno(_(32000), 'Remove data as well?') self.transmission.remove(int(item.getProperty('TorrentID')), remove_data) if (controlID == 113): # Stop selected torrent item = list.getSelectedItem() if item: self.transmission.stop(int(item.getProperty('TorrentID'))) if (controlID == 114): # Start selected torrent item = list.getSelectedItem() if item: self.transmission.start(int(item.getProperty('TorrentID'))) if (controlID == 115): # Stop all torrents self.transmission.stop(self.torrents.keys()) if (controlID == 116): # Start all torrents self.transmission.start(self.torrents.keys()) if (controlID == 117): # Exit button self.close() if (controlID == 118): # Settings button prev_settings = common.get_settings() __settings__.openSettings() p = xbmcgui.DialogProgress() p.create(_(32000), _(32001)) # 'Transmission', 'Connecting to Transmission' try: self.transmission = common.get_rpc_client() self.updateTorrents() p.close() except: p.close() xbmcgui.Dialog().ok(_(32002), _(32901)) # restore settings self.set_settings(prev_settings) try: self.transmission = common.get_rpc_client() except err: xbmcgui.Dialog().ok(_(32002), _(32901)) self.close() if (controlID == 120): # A torrent was chosen, show details item = list.getSelectedItem() w = TorrentInfoGUI("script-Transmission-details.xml", __settings__.getAddonInfo('path') ,"Default") w.setTorrent(self.transmission, int(item.getProperty('TorrentID'))) w.doModal() del w