From 41b38b8392702e724609c6c6fd4def724d4f896e Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Mon, 19 Jan 2015 20:33:28 +0300 Subject: [PATCH] TC copy files from subfold --- .idea/workspace.xml | 278 ++++++++++++++++++++++++++++++++++---------- Core.py | 33 ++++-- Localization.py | 4 +- 3 files changed, 239 insertions(+), 76 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9cd4447..dd573eb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,11 +1,9 @@ - + - - - + @@ -37,11 +35,61 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -70,7 +118,7 @@ - + @@ -94,11 +142,9 @@ - - + + - - @@ -109,7 +155,6 @@ - @@ -125,16 +170,6 @@ - - - - - - - - - - @@ -314,7 +349,6 @@ - @@ -666,7 +701,11 @@ 1421616989982 1421616989982 - @@ -690,14 +729,15 @@ - + + - + @@ -707,7 +747,6 @@ - @@ -748,7 +787,8 @@ - @@ -761,8 +801,6 @@ - - @@ -773,7 +811,6 @@ - @@ -822,7 +859,47 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -831,8 +908,6 @@ - - @@ -843,7 +918,6 @@ - @@ -892,7 +966,47 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1003,14 +1117,6 @@ - - - - - - - - @@ -1019,13 +1125,6 @@ - - - - - - - @@ -1296,11 +1395,9 @@ - - + + - - @@ -1311,7 +1408,6 @@ - @@ -1326,10 +1422,66 @@ + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core.py b/Core.py index c234601..eb5db24 100644 --- a/Core.py +++ b/Core.py @@ -1023,8 +1023,8 @@ class Core: menu, dirs = [], [] contextMenustring = 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % (sys.argv[0], 'uTorrentBrowser', '%s') + get = params.get try: - get = params.get apps = json.loads(urllib.unquote_plus(get("url"))) except: apps = {} @@ -1046,16 +1046,12 @@ class Core: return if (ind or ind == 0) and action in ('0', '3'): Download().setprio_simple(hash, action, ind) - elif (ind or ind == 0) and action == 'play': + elif action in ['play','copy']: p, dllist, i, folder, filename = DownloadList, Download().listfiles(hash), 0, None, None for data in p: if data['id'] == hash: folder = data['dir'] break - for data in dllist: - if data[2] == int(ind): - filename = data[0] - break if isRemoteTorr(): t_dir = self.__settings__.getSetting("torrent_dir") torrent_replacement = self.__settings__.getSetting("torrent_replacement") @@ -1071,8 +1067,23 @@ class Core: return #print str(folder)+str(torrent_dir)+str(torrent_replacement)+str(tdir) folder = folder.replace(t_dir, torrent_replacement) - filename = os.path.join(folder, filename) - xbmc.executebuiltin('xbmc.PlayMedia("' + filename.encode('utf-8') + '")') + if (ind or ind == 0) and action == 'play': + for data in dllist: + if data[2] == int(ind): + filename = data[0] + break + filename = os.path.join(folder, filename) + xbmc.executebuiltin('xbmc.PlayMedia("' + filename.encode('utf-8') + '")') + elif tdir and action == 'copy': + path=os.path.join(folder, tdir) + dirs, files=xbmcvfs.listdir(path) + for file in files: + if not xbmcvfs.exists(os.path.join(path,file)): + xbmcvfs.delete(os.path.join(path,file)) + xbmcvfs.copy(os.path.join(path,file),os.path.join(folder,file)) + i=i+1 + showMessage(self.localize('Torrent-client Browser'), self.localize('Copied %d files!') % i, forced=True) + return elif not tdir and action not in ('0', '3'): Download().action_simple(action, hash) elif action in ('0', '3'): @@ -1127,7 +1138,7 @@ class Core: link = json.dumps(app) popup = [] folder = True - actions = [('3', self.localize('Start All Files')), ('0', self.localize('Stop All Files'))] + actions = [('3', self.localize('High Priority All Files')), ('copy', self.localize('Copy Files in Root')), ('0', self.localize('Skip All Files'))] for a, title in actions: app['action'] = a popup.append((self.localize(title), contextMenustring % urllib.quote_plus(json.dumps(app)))) @@ -1375,9 +1386,7 @@ class Core: x=-1 for i in myshows_files: x=x+1 - fileTitle = '' - fileTitle=myshows_sizes[str(i)] - fileTitle+=myshows_cut[x] + fileTitle=myshows_sizes[str(i)]+myshows_cut[x] myshows_items.append(fileTitle) myshows_items.append(unicode(myshows_lang(30400))) myshows_files.append('') diff --git a/Localization.py b/Localization.py index b729d34..8d83285 100644 --- a/Localization.py +++ b/Localization.py @@ -83,7 +83,7 @@ dictionary = { 'Retry': 'Повторная попытка', '%ds has left': 'Осталось %d попыток', 'File failed to play! Do you want to RETRY and buffer more?': 'Ошибка проигрывания файла! Хотите предзагрузить больше и повторить?', - 'High Priority All Files': 'Высокий Приоритет Всем Файлам', + 'High Priority Files': 'Высокий Приоритет Файлам', 'Skip All Files': 'Пропустить Все Файлы', 'Start': 'Пуск', 'Stop': 'Стоп', @@ -219,6 +219,8 @@ dictionary = { 'Stopped All!':'Все Остановлено!', 'Stop All':'Остановить Все', 'Keyboard':'Клавиатура', + 'Copy Files in Root':'Скопировать файлы в Корень', + 'Copied %d files!':'Скопировано %d файлов!', } }