Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- default.py 2012-03-30 15:36:08.120907926 -0700
- +++ .xbmc/addons/plugin.program.piratebay/default.py 2012-03-27 08:50:03.315088204 -0700
- @@ -6,6 +6,8 @@ import xbmcplugin
- import xbmcgui
- import xbmcvfs
- import xbmcaddon
- +import transmissionrpc
- +
- from BeautifulSoup import BeautifulSoup
- import StorageServer
- from webviewer import webviewer
- @@ -86,10 +88,11 @@ def getTorrents(url, page):
- for i in items:
- try:
- name = i('div')[0]('a')[0].string.encode('ascii', 'ignore')
- - info_url = 'http://thepiratebay.org'+i('a')[2]['href']
- - t_url = i('a')[4]['href']
- + info_url = 'http://thepiratebay.se/'+i('a')[2]['href']
- + t_url = i('a')[3]['href']
- le = i('td')[-1].string
- se = i('td')[-2].string
- + print '---tURL: '+t_url
- except:
- pass
- try:
- @@ -116,36 +119,8 @@ def getTorrents(url, page):
- def Download(url):
- - filename = str(url).split('/')[-1]
- - def download(url, dest):
- - dialog = xbmcgui.DialogProgress()
- - dialog.create('Downloading Torrent File','From the PirateBay', filename)
- - urllib.urlretrieve(url, dest, lambda nb, bs, fs, url = url: _pbhook(nb, bs, fs, url, dialog))
- - def _pbhook(numblocks, blocksize, filesize, url = None,dialog = None):
- - try:
- - percent = min((numblocks * blocksize * 100) / filesize, 100)
- - dialog.update(percent)
- - except:
- - percent = 100
- - dialog.update(percent)
- - if dialog.iscanceled():
- - dialog.close()
- - if addon.getSetting('download') == '':
- - addon.openSettings('download')
- - filepath = xbmc.translatePath(os.path.join(addon.getSetting('download'),filename))
- - if 'smb:' in filepath:
- - if not xbmcvfs.exists(os.path.join( profile, 'temp')):
- - success = xbmcvfs.mkdir(os.path.join( profile, 'temp'))
- - dest = xbmc.makeLegalFilename(os.path.join( profile, 'temp', filename))
- - download(url, dest)
- - copy = xbmcvfs.copy(os.path.join( profile, 'temp', filename), os.path.join(addon.getSetting('download'), filename))
- - if copy:
- - xbmcvfs.delete(os.path.join( profile, 'temp', filename))
- - else:
- - if not xbmcvfs.exists(os.path.join(addon.getSetting('download'))):
- - success = xbmcvfs.mkdir(os.path.join(addon.getSetting('download')))
- - download(url, filepath)
- -
- + tc = transmissionrpc.Client('127.0.0.1', '9091', 'transmission', 'transmission')
- + tc.add_uri(url)
- def get_params():
- param=[]
- @@ -237,4 +212,4 @@ if sys.argv[1] == 'info':
- webviewer.getWebResult(sys.argv[2])
- else:
- - run_plugin()
- \ No newline at end of file
- + run_plugin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement