keep_files ask
parent
57136e9c8c
commit
472635beab
23
Core.py
23
Core.py
|
@ -138,7 +138,7 @@ class Core:
|
|||
self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png')
|
||||
self.drawItem('test', 'test', image=self.ROOT + '/icons/magnet.png')
|
||||
|
||||
if 'true' == self.__settings__.getSetting("keep_files"):
|
||||
if '0' != self.__settings__.getSetting("keep_files"):
|
||||
self.drawItem('< %s >' % self.localize('Clear Storage'), 'clearStorage', isFolder=True,
|
||||
image=self.ROOT + '/icons/clear.png')
|
||||
view_style('sectionMenu')
|
||||
|
@ -1287,16 +1287,21 @@ class Core:
|
|||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
|
||||
|
||||
def userStorage(self, params):
|
||||
if self.__settings__.getSetting("keep_files")=='true' \
|
||||
and self.__settings__.getSetting("ask_dir")=='true':
|
||||
try:
|
||||
save_folder = urllib.unquote_plus(params.get('save_folder'))
|
||||
except:
|
||||
save_folder = ''
|
||||
save=False
|
||||
if self.__settings__.getSetting("keep_files")=='2':
|
||||
dialog = xbmcgui.Dialog()
|
||||
save = dialog.yesno(self.localize('Ask to save'), self.localize('Would you like to save this file?'))
|
||||
if save:
|
||||
self.userStorageDirectory = os.path.join(self.userStorageDirectory, 'Saved Files')
|
||||
if self.__settings__.getSetting("keep_files")=='1' and\
|
||||
self.__settings__.getSetting("ask_dir")=='true' or\
|
||||
self.__settings__.getSetting("keep_files")=='2' and\
|
||||
self.__settings__.getSetting("ask_dir")=='true' and save:
|
||||
save_folder = unquote(params.get('save_folder'), '')
|
||||
if len(save_folder)>0:
|
||||
default=os.path.join(self.userStorageDirectory, save_folder)
|
||||
default = os.path.join(self.userStorageDirectory, save_folder)
|
||||
else:
|
||||
default=self.userStorageDirectory
|
||||
default = self.userStorageDirectory
|
||||
keyboard = xbmc.Keyboard(default, self.localize('Save to path') + ':')
|
||||
keyboard.doModal()
|
||||
dirname = keyboard.getText()
|
||||
|
|
|
@ -30,7 +30,7 @@ import xbmc
|
|||
import xbmcgui
|
||||
import xbmcvfs
|
||||
import Localization
|
||||
from functions import file_decode, file_encode, isSubtitle, DownloadDB
|
||||
from functions import file_decode, file_encode, isSubtitle, DownloadDB, log, debug
|
||||
from platform_pulsar import get_platform
|
||||
|
||||
|
||||
|
@ -320,9 +320,12 @@ class Libtorrent:
|
|||
|
||||
#tribler example never tested
|
||||
#self.session.set_severity_level(self.lt.alert.severity_levels.info)
|
||||
#self.session.add_extension(self.lt.create_ut_pex_plugin)
|
||||
#self.session.add_extension(self.lt.create_ut_metadata_plugin)
|
||||
#self.session.add_extension(self.lt.create_metadata_plugin)
|
||||
self.session.add_extension("ut_pex")
|
||||
self.session.add_extension("lt_trackers")
|
||||
self.session.add_extension("metadata_transfer")
|
||||
self.session.add_extension("ut_metadata")
|
||||
# Ban peers that sends bad data
|
||||
self.session.add_extension("smart_ban")
|
||||
|
||||
# Session settings
|
||||
session_settings = self.session.settings()
|
||||
|
@ -372,7 +375,7 @@ class Libtorrent:
|
|||
if None == self.magnetLink:
|
||||
self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo,
|
||||
'save_path': self.storageDirectory,
|
||||
'flags': 0x300,
|
||||
#'flags': 0x300,
|
||||
# 'storage_mode': self.lt.storage_mode_t.storage_mode_allocate,
|
||||
})
|
||||
else:
|
||||
|
@ -421,8 +424,11 @@ class Libtorrent:
|
|||
|
||||
def checkThread(self):
|
||||
if self.threadComplete == True:
|
||||
print 'checkThread KIIIIIIIIIIILLLLLLLLLLLLLLL'
|
||||
self.session.remove_torrent(self.torrentHandle)
|
||||
log('checkThread KIIIIIIIIIIILLLLLLLLLLLLLLL')
|
||||
try:
|
||||
self.session.remove_torrent(self.torrentHandle)
|
||||
except:
|
||||
log('RuntimeError: invalid torrent handle used')
|
||||
self.session.stop_natpmp()
|
||||
self.session.stop_upnp()
|
||||
self.session.stop_lsd()
|
||||
|
|
|
@ -264,6 +264,8 @@ def localize(text):
|
|||
'I deleted pre-installed ones, install them in Search Control Window!':'Теперь серчеры нужно устанавливать отдельно в Окне Управления Поиском!',
|
||||
'Torrenter didn\'t find %s searcher':'Торрентер не нашел серчер трекера %s',
|
||||
'Torrenter Tracker Install':'Установка трекеров в Torrenter',
|
||||
'Ask to save':'Спросить о сохранении',
|
||||
'Would you like to save this file?':'Хотите сохранить данный файл?',
|
||||
|
||||
},
|
||||
'uk': {
|
||||
|
|
|
@ -129,7 +129,7 @@ class TorrentPlayer(xbmc.Player):
|
|||
torrentFilesDirectory = 'torrents'
|
||||
debug = __settings__.getSetting('debug') == 'true'
|
||||
subs_dl = __settings__.getSetting('subs_dl') == 'true'
|
||||
seeding = __settings__.getSetting('keep_seeding') == 'true' and __settings__.getSetting('keep_files') == 'true'
|
||||
seeding = __settings__.getSetting('keep_seeding') == 'true' and __settings__.getSetting('keep_files') == '1'
|
||||
seeding_status = False
|
||||
seeding_run = False
|
||||
ids_video = None
|
||||
|
@ -171,7 +171,7 @@ class TorrentPlayer(xbmc.Player):
|
|||
self.torrent.stopSession()
|
||||
self.torrent.threadComplete = True
|
||||
self.torrent.checkThread()
|
||||
if 'false' == self.__settings__.getSetting("keep_files"):
|
||||
if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.userStorageDirectory:
|
||||
clearStorage(self.userStorageDirectory)
|
||||
else:
|
||||
if self.seeding_status:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.video.torrenter" name="Torrenter" version="2.3.3" provider-name="vadim.skorba, DiMartino">
|
||||
<addon id="plugin.video.torrenter" name="Torrenter" version="2.3.4" provider-name="vadim.skorba, DiMartino">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.1.0"/>
|
||||
<import addon="script.module.libtorrent"/>
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
[B]Version 2.3.3[/B]
|
||||
English changelog at http://bit.ly/1MfSVUP
|
||||
|
||||
[B]Version 2.3.4[/B]
|
||||
[+] Проигрыватель: Новая настройка - спрашивать о сохранении файла
|
||||
[+] Списки Медиа: Исправлен TheMovieDB для python 2.6
|
||||
|
||||
[B]Version 2.3.3[/B]
|
||||
[+] Поиск: Настройка количества потоков при поиске
|
||||
|
||||
[B]Version 2.3.2[/B]
|
||||
|
|
58
functions.py
58
functions.py
|
@ -53,7 +53,6 @@ __language__ = __settings__.getLocalizedString
|
|||
ROOT = __settings__.getAddonInfo('path') # .decode('utf-8').encode(sys.getfilesystemencoding())
|
||||
userStorageDirectory = __settings__.getSetting("storage")
|
||||
USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"
|
||||
torrentFilesDirectory = 'torrents'
|
||||
__addonpath__ = __settings__.getAddonInfo('path')
|
||||
icon = __addonpath__ + '/icon.png'
|
||||
debug = __settings__.getSetting("debug")
|
||||
|
@ -62,22 +61,40 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
|
|||
|
||||
|
||||
def clearStorage(userStorageDirectory):
|
||||
try:
|
||||
userStorageDirectory = userStorageDirectory.decode('utf-8')
|
||||
except:
|
||||
pass
|
||||
userStorageDirectory = decode(userStorageDirectory)
|
||||
if xbmcvfs.exists(userStorageDirectory + os.sep):
|
||||
import shutil
|
||||
|
||||
temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\')
|
||||
torrents_temp, i = None, 0
|
||||
while not torrents_temp or xbmcvfs.exists(torrents_temp):
|
||||
torrents_temp, saved_temp, i = None, None, ''
|
||||
while not torrents_temp or os.path.exists(torrents_temp) or os.path.exists(saved_temp):
|
||||
torrents_temp = os.path.join(temp, 'torrents' + str(i)) + os.sep
|
||||
i += 1
|
||||
shutil.move(os.path.join(userStorageDirectory, 'torrents'), torrents_temp)
|
||||
saved_temp = os.path.join(temp, 'Saved Files' + str(i)) + os.sep
|
||||
if i=='':
|
||||
i=0
|
||||
else:
|
||||
i += 1
|
||||
|
||||
torrents = os.path.join(userStorageDirectory, 'torrents')
|
||||
saved = os.path.join(userStorageDirectory, 'Saved Files')
|
||||
torrents_bool, saved_bool = False, False
|
||||
|
||||
if os.path.exists(torrents):
|
||||
torrents_bool = shutil.move(torrents, torrents_temp)
|
||||
torrents_bool = True
|
||||
|
||||
if os.path.exists(saved):
|
||||
saved_bool = shutil.move(saved, saved_temp)
|
||||
saved_bool = True
|
||||
|
||||
shutil.rmtree(userStorageDirectory, ignore_errors=True)
|
||||
xbmcvfs.mkdir(userStorageDirectory)
|
||||
shutil.move(torrents_temp, os.path.join(userStorageDirectory, 'torrents'))
|
||||
|
||||
if torrents_bool:
|
||||
shutil.move(torrents_temp, torrents)
|
||||
if saved_bool:
|
||||
shutil.move(saved_temp, saved)
|
||||
|
||||
DownloadDB().clear()
|
||||
showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True)
|
||||
|
||||
|
@ -1832,4 +1849,23 @@ def noActiveSerachers():
|
|||
Localization.localize('Would you like to install %s from "MyShows.me Kodi Repo" in Programs section?') % '',)
|
||||
if yes:
|
||||
xbmc.executebuiltin('Dialog.Close(all,true)')
|
||||
xbmc.executebuiltin('XBMC.ActivateWindow(Addonbrowser,addons://search/%s)' % ('Torrenter Searcher'))
|
||||
xbmc.executebuiltin('XBMC.ActivateWindow(Addonbrowser,addons://search/%s)' % ('Torrenter Searcher'))
|
||||
|
||||
def windows_check():
|
||||
import platform
|
||||
"""
|
||||
Checks if the current platform is Windows
|
||||
:returns: True or False
|
||||
:rtype: bool
|
||||
"""
|
||||
return platform.system() in ('Windows', 'Microsoft')
|
||||
|
||||
|
||||
def vista_check():
|
||||
import platform
|
||||
"""
|
||||
Checks if the current platform is Windows Vista
|
||||
:returns: True or False
|
||||
:rtype: bool
|
||||
"""
|
||||
return platform.release() == "Vista"
|
|
@ -40,6 +40,9 @@
|
|||
<string id="30040">Custom search option phrase</string>
|
||||
<string id="30041">Encryption</string>
|
||||
<string id="30042">Search Thread Number</string>
|
||||
<string id="30043">Delete files</string>
|
||||
<string id="30044">Save files</string>
|
||||
<string id="30045">Ask to save</string>
|
||||
<string id="30101">Interface</string>
|
||||
<string id="30102">P2P Network</string>
|
||||
<string id="30103">Advanced</string>
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
<string id="30040">Дополнительная фраза в вариантах поиска</string>
|
||||
<string id="30041">Шифрование</string>
|
||||
<string id="30042">Количество параллельных потоков поиска</string>
|
||||
<string id="30043">Удалять файлы</string>
|
||||
<string id="30044">Сохранять файлы</string>
|
||||
<string id="30045">Спросить о сохранении</string>
|
||||
<string id="30101">Интерфейс</string>
|
||||
<string id="30102">P2P Сеть</string>
|
||||
<string id="30103">Дополнительные</string>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<setting id="debug" type="bool" label="30015" default="false"/>
|
||||
</category>
|
||||
<category label="30102">
|
||||
<setting id="torrent_player" type="enum" label="30023" default="0" lvalues="30021|30022" />
|
||||
<setting id="torrent_player" type="enum" label="30023" default="0" lvalues="30021|30022" />
|
||||
<setting id="storage" type="folder" label="30004" default=""/>
|
||||
<setting id="keep_files" type="bool" label="30008" default="true"/>
|
||||
<setting id="keep_files" type="enum" label="30008" default="1" lvalues="30043|30044|30045"/>
|
||||
<setting id="ask_dir" type="bool" label="30031" default="false" enable="eq(-1,true)" />
|
||||
<setting id="next_dl" type="bool" label="30013" default="true" visible="eq(-4,0)"/>
|
||||
<setting id="upload_limit" type="number" label="30010" default="0" visible="eq(-5,0)"/>
|
||||
|
|
Loading…
Reference in New Issue