コード例 #1
0
ファイル: search.py プロジェクト: Flaykz/Transmission-KODI
 def __init__(self):
     self.t = t411()
コード例 #2
0
ファイル: gui.py プロジェクト: Flaykz/Transmission-KODI
 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),
             (_(32209), search.CPasBien),
             (_(32210), search.GetStrike),
             (_(32211), search.T411),
         ]
         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