From e34f81208ad728497323ec28801fb6547a544d69 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sun, 9 Aug 2015 18:04:28 +0300 Subject: [PATCH] tmp fix --- Core.py | 66 +++++++++++++++++++++++++++++----------------------- functions.py | 26 +++++++++++++++++---- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/Core.py b/Core.py index 80e92eb..753b6a5 100644 --- a/Core.py +++ b/Core.py @@ -27,8 +27,6 @@ import xbmcgui import xbmcplugin import xbmcvfs from functions import * -from platform_pulsar import get_platform - class Core: __plugin__ = sys.modules["__main__"].__plugin__ @@ -36,7 +34,6 @@ class Core: ROOT = sys.modules["__main__"].__root__ #.decode('utf-8').encode(sys.getfilesystemencoding()) userStorageDirectory = file_encode(__settings__.getSetting("storage")) torrentFilesDirectory = 'torrents' - platform = get_platform() debug = __settings__.getSetting('debug') == 'true' torrent_player=__settings__.getSetting("torrent_player") history_bool = __settings__.getSetting('history') == 'true' @@ -52,22 +49,10 @@ class Core: def __init__(self): print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__ if 0 == len(self.userStorageDirectory): - try: - temp_dir = tempfile.gettempdir() - except: - if not self.platform['system']=='android': - temp_dir = tempdir() - else: - dialog=xbmcgui.Dialog() - dialog.ok(self.localize('Android Support'), - self.localize('Android has no temprorary folder'), - self.localize('Please specify storage folder in Settings!')) - self.__settings__.openSettings() - temp_dir = file_encode(self.__settings__.getSetting("storage")) - + download_dir = download_dir_check() else: - temp_dir = self.userStorageDirectory - self.userStorageDirectory = os.path.join(temp_dir, 'Torrenter') + download_dir = self.userStorageDirectory + self.userStorageDirectory = os.path.join(download_dir, 'Torrenter') def sectionMenu(self): if self.__settings__.getSetting('plugin_name')!=self.__plugin__: @@ -249,17 +234,17 @@ class Core: lockView('wide') def test(self, params={}): - from BTClientPlayer import BTClientPlayer - torrentUrl='D:\\ntest.torrent' - params['url']='0' - if not xbmcvfs.exists(torrentUrl): - action = xbmcgui.Dialog() - torrentUrl = action.browse(1, self.localize('Choose .torrent in video library'), 'video', '.torrent') - if torrentUrl and xbmcvfs.exists(torrentUrl): - if 0 != len(torrentUrl): - self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) - else: - print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content" + #from BTClientPlayer import BTClientPlayer + #torrentUrl='D:\\ntest.torrent' + #params['url']='0' + #if not xbmcvfs.exists(torrentUrl): + # action = xbmcgui.Dialog() + # torrentUrl = action.browse(1, self.localize('Choose .torrent in video library'), 'video', '.torrent') + #if torrentUrl and xbmcvfs.exists(torrentUrl): + # if 0 != len(torrentUrl): + # self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) + # else: + # print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content" #path='http://127.0.0.1:5001/Inception.2010.1080p.BluRay.x264.5xRus.Eng-Otaibi.mkv' #listitem = xbmcgui.ListItem('Inception.2010.1080p.BluRay.x264.5xRus.Eng-Otaibi.mkv', path=path) #playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) @@ -267,6 +252,29 @@ class Core: #playlist.add(path, listitem) #xbmc.Player().play(playlist) + try: + import cherrytorrent + http_config = { + 'port': 8089, + } + + torrent_config = { + 'port': 6900, + 'max_download_rate': 0, + 'max_upload_rate': 0, + 'keep_files': False + } + server = cherrytorrent.Server(http_config, torrent_config) + server.run() + url="http://localhost:8089/add?uri=magnet%3A%3Fxt%3Durn%3Abtih%3Ac39fe3eefbdb62da9c27eb6398ff4a7d2e26e7ab%26dn%3Dbig%2Bbuck%2Bbunny%2Bbdrip%2Bxvid%2Bmedic%26tr%3Dudp%253A%252F%252Ftracker.publicbt.com%253A80%252Fannounce%26tr%3Dudp%253A%252F%252Fopen.demonii.com%253A1337" + print str(get_url('',url)) + xbmc.sleep(3000) + path="http://localhost:8089/video"#?info_hash=c39fe3eefbdb62da9c27eb6398ff4a7d2e26e7ab + xbmc.Player().play(path) + xbmc.sleep(30000) + finally: + get_url('',"http://localhost:8089/shutdown") + def DownloadStatus(self, params={}): db = DownloadDB() get = params.get diff --git a/functions.py b/functions.py index 067384f..584ae88 100644 --- a/functions.py +++ b/functions.py @@ -1331,9 +1331,8 @@ def file_decode(filename): def file_encode(filename): - if not __settings__.getSetting('delete_russian') == 'true': - if sys.getfilesystemencoding() == 'mbcs' and isAsciiString(filename): - filename = filename.decode('cp1251').encode('utf-8') + if sys.getfilesystemencoding() == 'mbcs' and isAsciiString(filename): + filename = filename.decode('cp1251').encode('utf-8') return filename @@ -1820,4 +1819,23 @@ def check_network_advancedsettings(): Localization.localize('Please, restart Kodi now!')) print 'Restart Kodi' else: - print 'UPDATE advancedsettings.xml disabled by user!' \ No newline at end of file + print 'UPDATE advancedsettings.xml disabled by user!' + +def download_dir_check(): + from platform_pulsar import get_platform + import tempfile + platform = get_platform() + + dialog=xbmcgui.Dialog() + dialog.ok(Localization.localize('Torrenter'), + Localization.localize('Please specify storage folder in Settings!')) + __settings__.openSettings() + + try: + if not platform['system']=='android': + download_dir = tempfile.gettempdir() + else: + download_dir = tempdir() + except: + download_dir = tempdir() + return download_dir \ No newline at end of file