tmp fix
parent
21490a342f
commit
e34f81208a
66
Core.py
66
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
|
||||
|
|
24
functions.py
24
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
|
||||
|
||||
|
||||
|
@ -1821,3 +1820,22 @@ def check_network_advancedsettings():
|
|||
print 'Restart Kodi'
|
||||
else:
|
||||
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