From 23da8f77fd3999361d44885a43580f279ecbd1ac Mon Sep 17 00:00:00 2001 From: Palatosino Date: Sun, 8 May 2016 13:58:59 +0200 Subject: [PATCH 1/3] Fix magnetToTorrent magnetToTorrent was broken because torrentFile.files is not indexable (but is iterable). The only reason to use files[0] is to generate a "baseName" that is finally used to do self.md5(baseName) for the torrent file. I can iterate to the first element (to emulate files[0]) and get the name, but I think that is useless. We can remove this and use the magnet. I think that the best will be use the magnet ID information from the magnet link, not all the magnet, to remove optional arguments, but his is acceptable as a fast fix, and much better that the initial approach that can colisitionate with other files that have the same initial file (imagine a README.txt!!!!) --- SkorbaLoader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SkorbaLoader.py b/SkorbaLoader.py index 020a550..285bd5b 100644 --- a/SkorbaLoader.py +++ b/SkorbaLoader.py @@ -188,10 +188,9 @@ class SkorbaLoader: if torrentInfo: try: torrentFile = self.lt.create_torrent(torrentInfo) - baseName = os.path.basename(self.storageDirectory + os.sep + torrentInfo.files()[0].path) if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath) - self.torrentFile = self.torrentFilesPath + self.md5(baseName) + '.torrent' + self.torrentFile = self.torrentFilesPath + self.md5(magnet) + '.torrent' torentFileHandler = xbmcvfs.File(self.torrentFile, "w+b") torentFileHandler.write(self.lt.bencode(torrentFile.generate())) torentFileHandler.close() From 5e98bb1b89690d63364479c7f76ff79325cfa2cb Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sat, 14 May 2016 12:04:25 +0300 Subject: [PATCH 2/3] 2016 fix --- .idea/workspace.xml | 303 +++++++++++++++++++----------- Content.py | 3 +- resources/contenters/CXZ.py | 4 +- resources/contenters/IMDB.py | 3 +- resources/contenters/KinoPoisk.py | 3 +- 5 files changed, 198 insertions(+), 118 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index cc551c0..8e0ab87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,11 @@ - - + + + + @@ -34,11 +36,11 @@ - + - - + + @@ -129,7 +131,7 @@ - + @@ -139,6 +141,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -190,7 +238,7 @@ - + @@ -600,8 +648,8 @@ - - + + @@ -712,10 +760,6 @@ @@ -797,8 +845,6 @@ - - @@ -849,8 +895,28 @@ + + + + + + + + + + + + @@ -1047,13 +1113,6 @@ @@ -1410,7 +1476,7 @@ - + @@ -1440,7 +1506,6 @@ - @@ -1465,7 +1530,8 @@ - @@ -1474,34 +1540,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1667,6 +1705,7 @@ + @@ -1767,17 +1806,6 @@ - - - - - - - - - - - @@ -1820,8 +1848,8 @@ - - + + @@ -1897,54 +1925,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2348,5 +2331,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Content.py b/Content.py index 8d4da4a..8322bce 100644 --- a/Content.py +++ b/Content.py @@ -26,6 +26,7 @@ import re from StringIO import StringIO import gzip import HTMLParser +from datetime import date import Localization from functions import log, debug @@ -89,7 +90,7 @@ class Content: } } - for y in range(2015, 1970, -1): + for y in range(date.today().year, 1970, -1): category_dict['year'][str(y)] = (str(y), '/top/y/%s/' % str(y)) def get_contentList(self, category, subcategory=None, apps_property=None): diff --git a/resources/contenters/CXZ.py b/resources/contenters/CXZ.py index b9b4c5f..964e014 100644 --- a/resources/contenters/CXZ.py +++ b/resources/contenters/CXZ.py @@ -22,7 +22,7 @@ import re import Content from BeautifulSoup import BeautifulSoup - +from datetime import date def make_category_dict(): category_dict = { @@ -72,7 +72,7 @@ def make_category_dict(): x[0], x[1] + 'view=list', {'page': x[1] + 'view=list&page=%d', 'increase': 1, 'second_page': 1}) category_dict['year'] = {'year': 'by Year', } - for y in range(2015, 1970, -1): + for y in range(date.today().year, 1970, -1): category_dict['year'][str(y)] = (str(y), '/films/year/%s/' % str(y), {'page': '/films/year/%s/' % str(y) + '?view=list&page=%d', 'increase': 1, 'second_page': 1}) diff --git a/resources/contenters/IMDB.py b/resources/contenters/IMDB.py index 1956a79..334648e 100644 --- a/resources/contenters/IMDB.py +++ b/resources/contenters/IMDB.py @@ -23,6 +23,7 @@ import HTMLParser import Content from BeautifulSoup import BeautifulSoup +from datetime import date class IMDB(Content.Content): @@ -65,7 +66,7 @@ class IMDB(Content.Content): } } - for y in range(2015, 1970, -1): + for y in range(date.today().year, 1970, -1): category_dict['year'][str(y)] = (str(y), '/year/%s/' % str(y)) regex_list = [] diff --git a/resources/contenters/KinoPoisk.py b/resources/contenters/KinoPoisk.py index e49e2f9..d8f040b 100644 --- a/resources/contenters/KinoPoisk.py +++ b/resources/contenters/KinoPoisk.py @@ -20,6 +20,7 @@ import re import socket +from datetime import date import Content from BeautifulSoup import BeautifulSoup @@ -70,7 +71,7 @@ class KinoPoisk(Content.Content): x[0], x[1] + 'perpage/25/', {'page': x[1] + 'perpage/25/page/%d/', 'increase': 1, 'second_page': 2}) category_dict['year'] = {'year': 'by Year', } - for y in range(2015, 1970, -1): + for y in range(date.today().year, 1970, -1): category_dict['year'][str(y)] = (str(y), '/s/type/film/list/1/m_act[year]/%s/' % str(y) + 'perpage/25/', {'page': '/s/type/film/list/1/m_act[year]/%s/' % str(y) + 'perpage/25/page/%d/', 'increase': 1, 'second_page': 2}) From 43fe7d5c6f7faf3ff03757324a31eb5427867b75 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sat, 28 May 2016 08:42:49 +0300 Subject: [PATCH 3/3] dht off --- Anteoloader.py | 3 ++- Core.py | 34 +++++++++++++++++++++++--- Inposloader.py | 3 ++- SkorbaLoader.py | 12 +++++---- resources/language/English/strings.xml | 1 + resources/language/Russian/strings.xml | 1 + resources/settings.xml | 1 + 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Anteoloader.py b/Anteoloader.py index 4c26133..4eae5fa 100644 --- a/Anteoloader.py +++ b/Anteoloader.py @@ -370,6 +370,7 @@ class AnteoPlayer(xbmc.Player): keep_files = True resume_file=os.path.join(self.userStorageDirectory, 'torrents', os.path.basename(self.torrentUrl)+'.resume_data') + enable_dht = self.__settings__.getSetting("enable_dht") == 'true' dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"] user_agent = 'uTorrent/2200(24683)' self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024 @@ -378,7 +379,7 @@ class AnteoPlayer(xbmc.Player): connections_limit=connections_limit, download_kbps=download_limit, upload_kbps=upload_limit, encryption=encryption, keep_complete=keep_complete, keep_incomplete=keep_incomplete, dht_routers=dht_routers, use_random_port=use_random_port, listen_port=listen_port, - keep_files=keep_files, user_agent=user_agent, resume_file=resume_file) + keep_files=keep_files, user_agent=user_agent, resume_file=resume_file, enable_dht=enable_dht) def buffer(self): #self.pre_buffer_bytes = 30*1024*1024 #30 MB diff --git a/Core.py b/Core.py index 8e24223..d667c03 100644 --- a/Core.py +++ b/Core.py @@ -909,7 +909,7 @@ class Core: kinometa = self.Scraper.scraper(scraper, {'label': title, 'search': search, 'year': year}, self.language) - #print 'kinometa:'+str(kinometa) + log('kinometa:'+str(kinometa)) for section in kinometa.keys(): if isinstance(kinometa[section], dict): @@ -935,7 +935,13 @@ class Core: else: title = meta.get('info').get('title') - listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img) + listitem = xbmcgui.ListItem(title) + images = {'thumb': img, #'icon': img, + 'poster': img,# 'banner': img, + #'fanart': img, 'landscape': img, + # 'clearart': image, 'clearlogo': image, + } + listitem.setArt(images) listitem.setInfo(type='Video', infoLabels=info) if meta: listitem=itemScrap(listitem, meta) @@ -1102,7 +1108,29 @@ class Core: def drawItem(self, title, action, link='', image='', isFolder=True, contextMenu=None, replaceMenu=True, action2='', fileSize=0L, info={}): #log('[drawItem]:'+str((title, action, image, isFolder, contextMenu, replaceMenu, action2, info))) - listitem = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image) + listitem = xbmcgui.ListItem(title) + images = {'icon':image, 'thumb':image} + images = {'icon': image, 'thumb': image, + 'poster': image, 'banner': image, + 'fanart': image, 'landscape': image, + #'clearart': image, 'clearlogo': image, + } + listitem.setArt(images) + """ + setArt(values) -- Sets the listitem's art + values : dictionary - pairs of { label: value }. + - Some default art values (any string possible): + - thumb : string - image filename + - poster : string - image filename + - banner : string - image filename + - fanart : string - image filename + - clearart : string - image filename + - clearlogo : string - image filename + - landscape : string - image filename + - icon : string - image filename + example: + - self.list.getSelectedItem().setArt({ 'poster': 'poster.png', 'banner' : 'banner.png' }) + """ if not info: info = {"Title": title, "plot": title} if not isFolder and fileSize: info['size'] = fileSize diff --git a/Inposloader.py b/Inposloader.py index 3be50f2..bd5f2eb 100644 --- a/Inposloader.py +++ b/Inposloader.py @@ -137,13 +137,14 @@ class InposLoader: keep_complete = True keep_incomplete = True + enable_dht = self.__settings__.getSetting("enable_dht") == 'true' dht_routers = ["router.bittorrent.com:6881", "router.utorrent.com:6881"] user_agent = 'uTorrent/2200(24683)' self.engine = Engine(uri=file_url(self.torrentFile), download_path=self.storageDirectory, connections_limit=connections_limit, encryption=encryption, keep_complete=keep_complete, keep_incomplete=keep_incomplete, dht_routers=dht_routers, use_random_port=use_random_port, listen_port=listen_port, - user_agent=user_agent) + user_agent=user_agent, enable_dht=enable_dht) def localize(self, string): try: diff --git a/SkorbaLoader.py b/SkorbaLoader.py index 285bd5b..30b02c4 100644 --- a/SkorbaLoader.py +++ b/SkorbaLoader.py @@ -46,6 +46,7 @@ class SkorbaLoader: lt = None save_resume_data = None __settings__ = sys.modules["__main__"].__settings__ + enable_dht = __settings__.getSetting("enable_dht") == 'true' def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'): self.storageDirectory = storageDirectory @@ -163,7 +164,7 @@ class SkorbaLoader: iterator = 0 while iterator < 100: xbmc.sleep(500) - self.torrentHandle.force_dht_announce() + if self.enable_dht: self.torrentHandle.force_dht_announce() progressBar.update(iterator, Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting')+'.' * (iterator % 4), ' ') iterator += 1 if progressBar.iscanceled(): @@ -339,9 +340,10 @@ class SkorbaLoader: self.session = self.lt.session() self.session.set_alert_mask(self.lt.alert.category_t.error_notification | self.lt.alert.category_t.status_notification | self.lt.alert.category_t.storage_notification) #self.session.set_alert_mask(self.lt.alert.category_t.all_categories) - self.session.add_dht_router("router.bittorrent.com", 6881) - self.session.add_dht_router("router.utorrent.com", 6881) - self.session.start_dht() + if self.enable_dht: + self.session.add_dht_router("router.bittorrent.com", 6881) + self.session.add_dht_router("router.utorrent.com", 6881) + self.session.start_dht() self.session.start_lsd() self.session.start_upnp() self.session.start_natpmp() @@ -481,7 +483,7 @@ class SkorbaLoader: self.session.stop_natpmp() self.session.stop_upnp() self.session.stop_lsd() - self.session.stop_dht() + if self.enable_dht: self.session.stop_dht() def resume_data(self): wasPaused=self.session.is_paused() diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 39e3cb3..8897896 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -67,6 +67,7 @@ Aeon Nox (by joyrider) pyrrent2http (python-libtorrent via http) Append size to file name + Enable DHT Interface P2P Network Advanced diff --git a/resources/language/Russian/strings.xml b/resources/language/Russian/strings.xml index a6be9a9..fb67ec9 100644 --- a/resources/language/Russian/strings.xml +++ b/resources/language/Russian/strings.xml @@ -67,6 +67,7 @@ Aeon Nox (от joyrider) pyrrent2http (python-libtorrent по http) Добавлять размер к имени файла + Включить DHT Интерфейс P2P Сеть Дополнительные diff --git a/resources/settings.xml b/resources/settings.xml index bddb0dd..43c2b1d 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -69,6 +69,7 @@ +