keep_files ask

pull/1/head
DiMartinoXBMC 2015-07-20 19:31:37 +03:00
parent 57136e9c8c
commit 472635beab
10 changed files with 94 additions and 33 deletions

19
Core.py
View File

@ -138,7 +138,7 @@ class Core:
self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png') self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png')
self.drawItem('test', 'test', 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, self.drawItem('< %s >' % self.localize('Clear Storage'), 'clearStorage', isFolder=True,
image=self.ROOT + '/icons/clear.png') image=self.ROOT + '/icons/clear.png')
view_style('sectionMenu') view_style('sectionMenu')
@ -1287,12 +1287,17 @@ class Core:
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def userStorage(self, params): def userStorage(self, params):
if self.__settings__.getSetting("keep_files")=='true' \ save=False
and self.__settings__.getSetting("ask_dir")=='true': if self.__settings__.getSetting("keep_files")=='2':
try: dialog = xbmcgui.Dialog()
save_folder = urllib.unquote_plus(params.get('save_folder')) save = dialog.yesno(self.localize('Ask to save'), self.localize('Would you like to save this file?'))
except: if save:
save_folder = '' 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: if len(save_folder)>0:
default = os.path.join(self.userStorageDirectory, save_folder) default = os.path.join(self.userStorageDirectory, save_folder)
else: else:

View File

@ -30,7 +30,7 @@ import xbmc
import xbmcgui import xbmcgui
import xbmcvfs import xbmcvfs
import Localization 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 from platform_pulsar import get_platform
@ -320,9 +320,12 @@ class Libtorrent:
#tribler example never tested #tribler example never tested
#self.session.set_severity_level(self.lt.alert.severity_levels.info) #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("ut_pex")
#self.session.add_extension(self.lt.create_ut_metadata_plugin) self.session.add_extension("lt_trackers")
#self.session.add_extension(self.lt.create_metadata_plugin) 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
session_settings = self.session.settings() session_settings = self.session.settings()
@ -372,7 +375,7 @@ class Libtorrent:
if None == self.magnetLink: if None == self.magnetLink:
self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo, self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo,
'save_path': self.storageDirectory, 'save_path': self.storageDirectory,
'flags': 0x300, #'flags': 0x300,
# 'storage_mode': self.lt.storage_mode_t.storage_mode_allocate, # 'storage_mode': self.lt.storage_mode_t.storage_mode_allocate,
}) })
else: else:
@ -421,8 +424,11 @@ class Libtorrent:
def checkThread(self): def checkThread(self):
if self.threadComplete == True: if self.threadComplete == True:
print 'checkThread KIIIIIIIIIIILLLLLLLLLLLLLLL' log('checkThread KIIIIIIIIIIILLLLLLLLLLLLLLL')
try:
self.session.remove_torrent(self.torrentHandle) self.session.remove_torrent(self.torrentHandle)
except:
log('RuntimeError: invalid torrent handle used')
self.session.stop_natpmp() self.session.stop_natpmp()
self.session.stop_upnp() self.session.stop_upnp()
self.session.stop_lsd() self.session.stop_lsd()

View File

@ -264,6 +264,8 @@ def localize(text):
'I deleted pre-installed ones, install them in Search Control Window!':'Теперь серчеры нужно устанавливать отдельно в Окне Управления Поиском!', 'I deleted pre-installed ones, install them in Search Control Window!':'Теперь серчеры нужно устанавливать отдельно в Окне Управления Поиском!',
'Torrenter didn\'t find %s searcher':'Торрентер не нашел серчер трекера %s', 'Torrenter didn\'t find %s searcher':'Торрентер не нашел серчер трекера %s',
'Torrenter Tracker Install':'Установка трекеров в Torrenter', 'Torrenter Tracker Install':'Установка трекеров в Torrenter',
'Ask to save':'Спросить о сохранении',
'Would you like to save this file?':'Хотите сохранить данный файл?',
}, },
'uk': { 'uk': {

View File

@ -129,7 +129,7 @@ class TorrentPlayer(xbmc.Player):
torrentFilesDirectory = 'torrents' torrentFilesDirectory = 'torrents'
debug = __settings__.getSetting('debug') == 'true' debug = __settings__.getSetting('debug') == 'true'
subs_dl = __settings__.getSetting('subs_dl') == '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_status = False
seeding_run = False seeding_run = False
ids_video = None ids_video = None
@ -171,7 +171,7 @@ class TorrentPlayer(xbmc.Player):
self.torrent.stopSession() self.torrent.stopSession()
self.torrent.threadComplete = True self.torrent.threadComplete = True
self.torrent.checkThread() 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) clearStorage(self.userStorageDirectory)
else: else:
if self.seeding_status: if self.seeding_status:

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?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> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent"/> <import addon="script.module.libtorrent"/>

View File

@ -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] [B]Version 2.3.2[/B]

View File

@ -53,7 +53,6 @@ __language__ = __settings__.getLocalizedString
ROOT = __settings__.getAddonInfo('path') # .decode('utf-8').encode(sys.getfilesystemencoding()) ROOT = __settings__.getAddonInfo('path') # .decode('utf-8').encode(sys.getfilesystemencoding())
userStorageDirectory = __settings__.getSetting("storage") userStorageDirectory = __settings__.getSetting("storage")
USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0" USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"
torrentFilesDirectory = 'torrents'
__addonpath__ = __settings__.getAddonInfo('path') __addonpath__ = __settings__.getAddonInfo('path')
icon = __addonpath__ + '/icon.png' icon = __addonpath__ + '/icon.png'
debug = __settings__.getSetting("debug") debug = __settings__.getSetting("debug")
@ -62,22 +61,40 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
def clearStorage(userStorageDirectory): def clearStorage(userStorageDirectory):
try: userStorageDirectory = decode(userStorageDirectory)
userStorageDirectory = userStorageDirectory.decode('utf-8')
except:
pass
if xbmcvfs.exists(userStorageDirectory + os.sep): if xbmcvfs.exists(userStorageDirectory + os.sep):
import shutil import shutil
temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\') temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\')
torrents_temp, i = None, 0 torrents_temp, saved_temp, i = None, None, ''
while not torrents_temp or xbmcvfs.exists(torrents_temp): 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 torrents_temp = os.path.join(temp, 'torrents' + str(i)) + os.sep
saved_temp = os.path.join(temp, 'Saved Files' + str(i)) + os.sep
if i=='':
i=0
else:
i += 1 i += 1
shutil.move(os.path.join(userStorageDirectory, 'torrents'), torrents_temp)
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) shutil.rmtree(userStorageDirectory, ignore_errors=True)
xbmcvfs.mkdir(userStorageDirectory) 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() DownloadDB().clear()
showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True) showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True)
@ -1833,3 +1850,22 @@ def noActiveSerachers():
if yes: if yes:
xbmc.executebuiltin('Dialog.Close(all,true)') 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"

View File

@ -40,6 +40,9 @@
<string id="30040">Custom search option phrase</string> <string id="30040">Custom search option phrase</string>
<string id="30041">Encryption</string> <string id="30041">Encryption</string>
<string id="30042">Search Thread Number</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="30101">Interface</string>
<string id="30102">P2P Network</string> <string id="30102">P2P Network</string>
<string id="30103">Advanced</string> <string id="30103">Advanced</string>

View File

@ -40,6 +40,9 @@
<string id="30040">Дополнительная фраза в вариантах поиска</string> <string id="30040">Дополнительная фраза в вариантах поиска</string>
<string id="30041">Шифрование</string> <string id="30041">Шифрование</string>
<string id="30042">Количество параллельных потоков поиска</string> <string id="30042">Количество параллельных потоков поиска</string>
<string id="30043">Удалять файлы</string>
<string id="30044">Сохранять файлы</string>
<string id="30045">Спросить о сохранении</string>
<string id="30101">Интерфейс</string> <string id="30101">Интерфейс</string>
<string id="30102">P2P Сеть</string> <string id="30102">P2P Сеть</string>
<string id="30103">Дополнительные</string> <string id="30103">Дополнительные</string>

View File

@ -18,7 +18,7 @@
<category label="30102"> <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="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="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="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)"/> <setting id="upload_limit" type="number" label="30010" default="0" visible="eq(-5,0)"/>