tmp fix
parent
21490a342f
commit
e34f81208a
66
Core.py
66
Core.py
|
@ -27,8 +27,6 @@ import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
from functions import *
|
from functions import *
|
||||||
from platform_pulsar import get_platform
|
|
||||||
|
|
||||||
|
|
||||||
class Core:
|
class Core:
|
||||||
__plugin__ = sys.modules["__main__"].__plugin__
|
__plugin__ = sys.modules["__main__"].__plugin__
|
||||||
|
@ -36,7 +34,6 @@ class Core:
|
||||||
ROOT = sys.modules["__main__"].__root__ #.decode('utf-8').encode(sys.getfilesystemencoding())
|
ROOT = sys.modules["__main__"].__root__ #.decode('utf-8').encode(sys.getfilesystemencoding())
|
||||||
userStorageDirectory = file_encode(__settings__.getSetting("storage"))
|
userStorageDirectory = file_encode(__settings__.getSetting("storage"))
|
||||||
torrentFilesDirectory = 'torrents'
|
torrentFilesDirectory = 'torrents'
|
||||||
platform = get_platform()
|
|
||||||
debug = __settings__.getSetting('debug') == 'true'
|
debug = __settings__.getSetting('debug') == 'true'
|
||||||
torrent_player=__settings__.getSetting("torrent_player")
|
torrent_player=__settings__.getSetting("torrent_player")
|
||||||
history_bool = __settings__.getSetting('history') == 'true'
|
history_bool = __settings__.getSetting('history') == 'true'
|
||||||
|
@ -52,22 +49,10 @@ class Core:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
|
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
|
||||||
if 0 == len(self.userStorageDirectory):
|
if 0 == len(self.userStorageDirectory):
|
||||||
try:
|
download_dir = download_dir_check()
|
||||||
temp_dir = tempfile.gettempdir()
|
|
||||||
except:
|
|
||||||
if not self.platform['system']=='android':
|
|
||||||
temp_dir = tempdir()
|
|
||||||
else:
|
else:
|
||||||
dialog=xbmcgui.Dialog()
|
download_dir = self.userStorageDirectory
|
||||||
dialog.ok(self.localize('Android Support'),
|
self.userStorageDirectory = os.path.join(download_dir, 'Torrenter')
|
||||||
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"))
|
|
||||||
|
|
||||||
else:
|
|
||||||
temp_dir = self.userStorageDirectory
|
|
||||||
self.userStorageDirectory = os.path.join(temp_dir, 'Torrenter')
|
|
||||||
|
|
||||||
def sectionMenu(self):
|
def sectionMenu(self):
|
||||||
if self.__settings__.getSetting('plugin_name')!=self.__plugin__:
|
if self.__settings__.getSetting('plugin_name')!=self.__plugin__:
|
||||||
|
@ -249,17 +234,17 @@ class Core:
|
||||||
lockView('wide')
|
lockView('wide')
|
||||||
|
|
||||||
def test(self, params={}):
|
def test(self, params={}):
|
||||||
from BTClientPlayer import BTClientPlayer
|
#from BTClientPlayer import BTClientPlayer
|
||||||
torrentUrl='D:\\ntest.torrent'
|
#torrentUrl='D:\\ntest.torrent'
|
||||||
params['url']='0'
|
#params['url']='0'
|
||||||
if not xbmcvfs.exists(torrentUrl):
|
#if not xbmcvfs.exists(torrentUrl):
|
||||||
action = xbmcgui.Dialog()
|
# action = xbmcgui.Dialog()
|
||||||
torrentUrl = action.browse(1, self.localize('Choose .torrent in video library'), 'video', '.torrent')
|
# torrentUrl = action.browse(1, self.localize('Choose .torrent in video library'), 'video', '.torrent')
|
||||||
if torrentUrl and xbmcvfs.exists(torrentUrl):
|
#if torrentUrl and xbmcvfs.exists(torrentUrl):
|
||||||
if 0 != len(torrentUrl):
|
# if 0 != len(torrentUrl):
|
||||||
self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
# self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
||||||
else:
|
# else:
|
||||||
print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content"
|
# 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'
|
#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)
|
#listitem = xbmcgui.ListItem('Inception.2010.1080p.BluRay.x264.5xRus.Eng-Otaibi.mkv', path=path)
|
||||||
#playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
#playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||||
|
@ -267,6 +252,29 @@ class Core:
|
||||||
#playlist.add(path, listitem)
|
#playlist.add(path, listitem)
|
||||||
#xbmc.Player().play(playlist)
|
#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={}):
|
def DownloadStatus(self, params={}):
|
||||||
db = DownloadDB()
|
db = DownloadDB()
|
||||||
get = params.get
|
get = params.get
|
||||||
|
|
20
functions.py
20
functions.py
|
@ -1331,7 +1331,6 @@ def file_decode(filename):
|
||||||
|
|
||||||
|
|
||||||
def file_encode(filename):
|
def file_encode(filename):
|
||||||
if not __settings__.getSetting('delete_russian') == 'true':
|
|
||||||
if sys.getfilesystemencoding() == 'mbcs' and isAsciiString(filename):
|
if sys.getfilesystemencoding() == 'mbcs' and isAsciiString(filename):
|
||||||
filename = filename.decode('cp1251').encode('utf-8')
|
filename = filename.decode('cp1251').encode('utf-8')
|
||||||
return filename
|
return filename
|
||||||
|
@ -1821,3 +1820,22 @@ def check_network_advancedsettings():
|
||||||
print 'Restart Kodi'
|
print 'Restart Kodi'
|
||||||
else:
|
else:
|
||||||
print 'UPDATE advancedsettings.xml disabled by user!'
|
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
|
Loading…
Reference in New Issue