Don't like ads? PRO users don't see any ads ;-)
Guest

piratebay xbmc addon duct tape. #2

By: a guest on May 1st, 2012  |  syntax: None  |  size: 2.82 KB  |  hits: 187  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --- default.py  2012-01-30 09:12:12.000000000 -0700
  2. +++ newdefult.py        2012-05-01 14:58:19.647674071 -0700
  3. @@ -6,6 +6,8 @@
  4.  import xbmcgui
  5.  import xbmcvfs
  6.  import xbmcaddon
  7. +import transmissionrpc
  8. +
  9.  from BeautifulSoup import BeautifulSoup
  10.  import StorageServer
  11.  from webviewer import webviewer
  12. @@ -86,10 +88,11 @@
  13.          for i in items:
  14.              try:
  15.                  name = i('div')[0]('a')[0].string.encode('ascii', 'ignore')
  16. -                info_url = 'http://thepiratebay.org'+i('a')[2]['href']
  17. -                t_url = i('a')[4]['href']
  18. +                info_url = 'http://thepiratebay.se/'+i('a')[2]['href']
  19. +                t_url = i('a')[3]['href']
  20.                  le = i('td')[-1].string
  21.                  se = i('td')[-2].string
  22. +               print '---tURL: '+t_url
  23.              except:
  24.                  pass
  25.              try:
  26. @@ -116,36 +119,9 @@
  27.  
  28.  
  29.  def Download(url):
  30. -        filename = str(url).split('/')[-1]
  31. -        def download(url, dest):
  32. -            dialog = xbmcgui.DialogProgress()
  33. -            dialog.create('Downloading Torrent File','From the PirateBay', filename)
  34. -            urllib.urlretrieve(url, dest, lambda nb, bs, fs, url = url: _pbhook(nb, bs, fs, url, dialog))
  35. -        def _pbhook(numblocks, blocksize, filesize, url = None,dialog = None):
  36. -            try:
  37. -                percent = min((numblocks * blocksize * 100) / filesize, 100)
  38. -                dialog.update(percent)
  39. -            except:
  40. -                percent = 100
  41. -                dialog.update(percent)
  42. -            if dialog.iscanceled():
  43. -                dialog.close()
  44. -        if addon.getSetting('download') == '':
  45. -            addon.openSettings('download')
  46. -        filepath = xbmc.translatePath(os.path.join(addon.getSetting('download'),filename))
  47. -        if 'smb:' in filepath:
  48. -            if not xbmcvfs.exists(os.path.join( profile, 'temp')):
  49. -                success = xbmcvfs.mkdir(os.path.join( profile, 'temp'))
  50. -            dest = xbmc.makeLegalFilename(os.path.join( profile, 'temp', filename))
  51. -            download(url, dest)
  52. -            copy = xbmcvfs.copy(os.path.join( profile, 'temp', filename), os.path.join(addon.getSetting('download'), filename))
  53. -            if copy:
  54. -                xbmcvfs.delete(os.path.join( profile, 'temp', filename))
  55. -        else:
  56. -            if not xbmcvfs.exists(os.path.join(addon.getSetting('download'))):
  57. -                success = xbmcvfs.mkdir(os.path.join(addon.getSetting('download')))
  58. -            download(url, filepath)
  59. -
  60. +       tc = transmissionrpc.Client('127.0.0.1', '9091', 'transmission', 'transmission')
  61. +       tc.add_uri(url)
  62. +        tc.close()
  63.  
  64.  def get_params():
  65.          param=[]
  66. @@ -237,4 +213,4 @@
  67.      webviewer.getWebResult(sys.argv[2])
  68.  
  69.  else:
  70. -    run_plugin()
  71. \ No newline at end of file
  72. +    run_plugin()