Advertisement
Guest User

piratebay xbmc addon duct tape.

a guest
Mar 30th, 2012
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. --- default.py 2012-03-30 15:36:08.120907926 -0700
  2. +++ .xbmc/addons/plugin.program.piratebay/default.py 2012-03-27 08:50:03.315088204 -0700
  3. @@ -6,6 +6,8 @@ import xbmcplugin
  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 @@ def getTorrents(url, page):
  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,8 @@ def getTorrents(url, page):
  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.  
  63. def get_params():
  64. param=[]
  65. @@ -237,4 +212,4 @@ if sys.argv[1] == 'info':
  66. webviewer.getWebResult(sys.argv[2])
  67.  
  68. else:
  69. - run_plugin()
  70. \ No newline at end of file
  71. + run_plugin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement