new settings
This commit is contained in:
		
							parent
							
								
									dba0c4173a
								
							
						
					
					
						commit
						0b28b8d3ab
					
				
							
								
								
									
										1955
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1955
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
@ -37,7 +38,7 @@ import sys
 | 
				
			|||||||
from contextlib import contextmanager, closing, nested
 | 
					from contextlib import contextmanager, closing, nested
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from functions import calculate, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug
 | 
					from functions import calculate, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from torrent2http import State, Engine, MediaType
 | 
					from torrent2http import State, Engine, MediaType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -175,7 +176,7 @@ class AnteoLoader:
 | 
				
			|||||||
                iterator += 1
 | 
					                iterator += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for fs in files:
 | 
					            for fs in files:
 | 
				
			||||||
                stringdata = {"title": fs.name, "size": fs.size, "ind": fs.index,
 | 
					                stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
 | 
				
			||||||
                              'offset': fs.offset}
 | 
					                              'offset': fs.offset}
 | 
				
			||||||
                filelist.append(stringdata)
 | 
					                filelist.append(stringdata)
 | 
				
			||||||
        return filelist
 | 
					        return filelist
 | 
				
			||||||
@ -511,6 +512,7 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
                log('seekTime')
 | 
					                log('seekTime')
 | 
				
			||||||
            log('[AnteoPlayer]: seekTime - '+str(self.seek))
 | 
					            log('[AnteoPlayer]: seekTime - '+str(self.seek))
 | 
				
			||||||
            self.seekTime(self.seek)
 | 
					            self.seekTime(self.seek)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup_subs(self):
 | 
					    def setup_subs(self):
 | 
				
			||||||
@ -528,9 +530,8 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
                    xbmc.Player().setSubtitles(sub.url)
 | 
					                    xbmc.Player().setSubtitles(sub.url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def loop(self):
 | 
					    def loop(self):
 | 
				
			||||||
        debug_counter=0
 | 
					        debug_counter = 0
 | 
				
			||||||
        xbmc.sleep(1000)
 | 
					        pause = True
 | 
				
			||||||
 | 
					 | 
				
			||||||
        with closing(
 | 
					        with closing(
 | 
				
			||||||
                OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
 | 
					                OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
 | 
				
			||||||
            with nested(self.attach(overlay.show, self.on_playback_paused),
 | 
					            with nested(self.attach(overlay.show, self.on_playback_paused),
 | 
				
			||||||
@ -550,6 +551,10 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
                    overlay.text = "\n".join(self._get_status_lines(status, file_status))
 | 
					                    overlay.text = "\n".join(self._get_status_lines(status, file_status))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    self.iterator = int(file_status.progress * 100)
 | 
					                    self.iterator = int(file_status.progress * 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if pause and self.__settings__.getSetting("pause_onplay") == 'true':
 | 
				
			||||||
 | 
					                        pause = False
 | 
				
			||||||
 | 
					                        xbmc.Player().pause()
 | 
				
			||||||
                    xbmc.sleep(1000)
 | 
					                    xbmc.sleep(1000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    #if not self.seeding_run and self.iterator == 100 and self.seeding:
 | 
					                    #if not self.seeding_run and self.iterator == 100 and self.seeding:
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								Core.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Core.py
									
									
									
									
									
								
							@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
@ -260,7 +260,13 @@ class Core:
 | 
				
			|||||||
        #self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
 | 
					        #self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
 | 
				
			||||||
        log('userStorageDirectory - '+(self.userStorageDirectory))
 | 
					        log('userStorageDirectory - '+(self.userStorageDirectory))
 | 
				
			||||||
        log('is_writable - '+str(is_writable(self.userStorageDirectory)))
 | 
					        log('is_writable - '+str(is_writable(self.userStorageDirectory)))
 | 
				
			||||||
        #log('getsize - '+str(os.path.getsize(self.userStorageDirectory)))
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        log('getsize - '+str(os.path.getsize(self.userStorageDirectory)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        log('getDirectorySizeInBytes - '+str(getDirectorySizeInBytes(self.userStorageDirectory)))
 | 
				
			||||||
 | 
					        log('getDirectorySizeInGB - '+str(getDirectorySizeInGB(self.userStorageDirectory)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        import stat
 | 
					        import stat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
@ -1366,7 +1372,7 @@ class Core:
 | 
				
			|||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def clearStorage(self, params={}):
 | 
					    def clearStorage(self, params={}):
 | 
				
			||||||
        clearStorage(self.userStorageDirectory)
 | 
					        clearStorage(self.userStorageDirectory, force=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def magentPlayer(self, params={}):
 | 
					    def magentPlayer(self, params={}):
 | 
				
			||||||
        defaultKeyword = params.get('url')
 | 
					        defaultKeyword = params.get('url')
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
@ -349,9 +349,13 @@ class Libtorrent:
 | 
				
			|||||||
        self.session.start_upnp()
 | 
					        self.session.start_upnp()
 | 
				
			||||||
        self.session.start_natpmp()
 | 
					        self.session.start_natpmp()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.session.listen_on(6881, 6891)
 | 
					            port = int(self.__settings__.getSetting('listen_port'))
 | 
				
			||||||
 | 
					            self.session.listen_on(port, port+10)
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            log('listen_on(6881, 6891) error')
 | 
					            try:
 | 
				
			||||||
 | 
					                log('listen_on(%d, %d) error' %(port, port+10))
 | 
				
			||||||
 | 
					            except:
 | 
				
			||||||
 | 
					                log('listen_port %s error' %(self.__settings__.getSetting('listen_port')))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pc_config = int(self.__settings__.getSetting('pc_config'))
 | 
					        pc_config = int(self.__settings__.getSetting('pc_config'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								Player.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								Player.py
									
									
									
									
									
								
							@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
@ -336,11 +336,11 @@ class TorrentPlayer(xbmc.Player):
 | 
				
			|||||||
        xbmc.sleep(1000)
 | 
					        xbmc.sleep(1000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if response:
 | 
					        if response:
 | 
				
			||||||
            # xbmc.Player().play(path, listitem)
 | 
					            xbmc.Player().play(path, listitem)
 | 
				
			||||||
            playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
 | 
					            #playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
 | 
				
			||||||
            playlist.clear()
 | 
					            #playlist.clear()
 | 
				
			||||||
            playlist.add(path, listitem)
 | 
					            #playlist.add(path, listitem)
 | 
				
			||||||
            xbmc.Player().play(playlist)
 | 
					            #xbmc.Player().play(playlist)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            xbmc.sleep(2000)  # very important, do not edit this, podavan
 | 
					            xbmc.sleep(2000)  # very important, do not edit this, podavan
 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
@ -401,7 +401,7 @@ class TorrentPlayer(xbmc.Player):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def loop(self):
 | 
					    def loop(self):
 | 
				
			||||||
        debug_counter=0
 | 
					        debug_counter=0
 | 
				
			||||||
        xbmc.sleep(1000)
 | 
					        pause = True
 | 
				
			||||||
        self.torrent.torrentHandle.force_dht_announce()
 | 
					        self.torrent.torrentHandle.force_dht_announce()
 | 
				
			||||||
        with closing(
 | 
					        with closing(
 | 
				
			||||||
                OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
 | 
					                OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
 | 
				
			||||||
@ -420,6 +420,9 @@ class TorrentPlayer(xbmc.Player):
 | 
				
			|||||||
                    overlay.text = "\n".join(self._get_status_lines(status))
 | 
					                    overlay.text = "\n".join(self._get_status_lines(status))
 | 
				
			||||||
                    # downloadedSize = torrent.torrentHandle.file_progress()[contentId]
 | 
					                    # downloadedSize = torrent.torrentHandle.file_progress()[contentId]
 | 
				
			||||||
                    self.iterator = int(status.progress * 100)
 | 
					                    self.iterator = int(status.progress * 100)
 | 
				
			||||||
 | 
					                    if pause and self.__settings__.getSetting("pause_onplay") == 'true':
 | 
				
			||||||
 | 
					                        pause = False
 | 
				
			||||||
 | 
					                        xbmc.Player().pause()
 | 
				
			||||||
                    xbmc.sleep(1000)
 | 
					                    xbmc.sleep(1000)
 | 
				
			||||||
                    if self.iterator == 100 and self.next_dl:
 | 
					                    if self.iterator == 100 and self.next_dl:
 | 
				
			||||||
                        next_contentId_index = self.ids_video.index(str(self.contentId)) + 1
 | 
					                        next_contentId_index = self.ids_video.index(str(self.contentId)) + 1
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
@ -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.4.4" provider-name="DiMartino">
 | 
					<addon id="plugin.video.torrenter" name="Torrenter" version="2.4.5" provider-name="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"/>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,11 @@
 | 
				
			|||||||
English changelog at http://bit.ly/1MfSVUP
 | 
					English changelog at http://bit.ly/1MfSVUP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[B]Version 2.4.5[/B]
 | 
				
			||||||
 | 
					[+] Дополнительна секция настроек со специфическими опциями
 | 
				
			||||||
 | 
					[+] Минимальный размер хранилища при очищении
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[B]Version 2.4.4[/B]
 | 
					[B]Version 2.4.4[/B]
 | 
				
			||||||
[+] Кнопка редатировать в Истории Поиска
 | 
					[+] Кнопка редактировать в Истории Поиска
 | 
				
			||||||
[+] Переключатель автоматического запуска следующего эпизода
 | 
					[+] Переключатель автоматического запуска следующего эпизода
 | 
				
			||||||
[+] Исправлено ограничение скорости Torrent2HTTP, которое на самом деле измерялось в MB/s, а не Mbit/s
 | 
					[+] Исправлено ограничение скорости Torrent2HTTP, которое на самом деле измерялось в MB/s, а не Mbit/s
 | 
				
			||||||
[+] Настройки для девайсов/ПК разной мощности у python-libtorrent
 | 
					[+] Настройки для девайсов/ПК разной мощности у python-libtorrent
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										99
									
								
								functions.py
									
									
									
									
									
								
							
							
						
						
									
										99
									
								
								functions.py
									
									
									
									
									
								
							@ -2,7 +2,7 @@
 | 
				
			|||||||
'''
 | 
					'''
 | 
				
			||||||
    Torrenter v2 plugin for XBMC/Kodi
 | 
					    Torrenter v2 plugin for XBMC/Kodi
 | 
				
			||||||
    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
					    Copyright (C) 2012-2015 Vadim Skorba v1 - DiMartino v2
 | 
				
			||||||
    http://forum.kodi.tv/showthread.php?tid=214366
 | 
					    https://forums.tvaddons.ag/addon-releases/29224-torrenter-v2.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					    it under the terms of the GNU General Public License as published by
 | 
				
			||||||
@ -51,55 +51,58 @@ __version__ = __settings__.getAddonInfo('version')
 | 
				
			|||||||
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
 | 
					__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def clearStorage(userStorageDirectory):
 | 
					def clearStorage(userStorageDirectory, force = False):
 | 
				
			||||||
    userStorageDirectory = decode(userStorageDirectory)
 | 
					    userStorageDirectory = decode(userStorageDirectory)
 | 
				
			||||||
    #log('[clearStorage]: storage '+str(userStorageDirectory) + os.sep)
 | 
					    #log('[clearStorage]: storage '+str(userStorageDirectory) + os.sep)
 | 
				
			||||||
    if xbmcvfs.exists(userStorageDirectory + os.sep) or os.path.exists(userStorageDirectory):
 | 
					    min_storage_size = __settings__.getSetting("min_storage_size")
 | 
				
			||||||
        log('[clearStorage]: storage exists')
 | 
					    storage_size = getDirectorySizeInGB(userStorageDirectory)
 | 
				
			||||||
        import shutil
 | 
					    if storage_size >= min_storage_size or force:
 | 
				
			||||||
 | 
					        if xbmcvfs.exists(userStorageDirectory + os.sep) or os.path.exists(userStorageDirectory):
 | 
				
			||||||
 | 
					            log('[clearStorage]: storage exists')
 | 
				
			||||||
 | 
					            import shutil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\')
 | 
					            temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\')
 | 
				
			||||||
        torrents_temp, saved_temp, i = None, None, ''
 | 
					            torrents_temp, saved_temp, i = None, None, ''
 | 
				
			||||||
        while not torrents_temp or os.path.exists(torrents_temp) or os.path.exists(saved_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
 | 
					                saved_temp = os.path.join(temp, 'Saved Files' + str(i)) + os.sep
 | 
				
			||||||
            if i=='':
 | 
					                if i=='':
 | 
				
			||||||
                i=0
 | 
					                    i=0
 | 
				
			||||||
            else:
 | 
					                else:
 | 
				
			||||||
                i += 1
 | 
					                    i += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        torrents = os.path.join(userStorageDirectory, 'torrents')
 | 
					            torrents = os.path.join(userStorageDirectory, 'torrents')
 | 
				
			||||||
        saved = os.path.join(userStorageDirectory, 'Saved Files')
 | 
					            saved = os.path.join(userStorageDirectory, 'Saved Files')
 | 
				
			||||||
        torrents_bool, saved_bool = False, False
 | 
					            torrents_bool, saved_bool = False, False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if os.path.exists(torrents):
 | 
					            if os.path.exists(torrents):
 | 
				
			||||||
            shutil.move(torrents, torrents_temp)
 | 
					                shutil.move(torrents, torrents_temp)
 | 
				
			||||||
            torrents_bool = True
 | 
					                torrents_bool = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if os.path.exists(saved):
 | 
					            if os.path.exists(saved):
 | 
				
			||||||
            shutil.move(saved, saved_temp)
 | 
					                shutil.move(saved, saved_temp)
 | 
				
			||||||
            saved_bool = True
 | 
					                saved_bool = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        shutil.rmtree(userStorageDirectory.encode('utf-8'), ignore_errors=True)
 | 
					            shutil.rmtree(userStorageDirectory.encode('utf-8'), ignore_errors=True)
 | 
				
			||||||
        xbmcvfs.mkdir(userStorageDirectory)
 | 
					            xbmcvfs.mkdir(userStorageDirectory)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if torrents_bool:
 | 
					            if torrents_bool:
 | 
				
			||||||
            shutil.move(torrents_temp, torrents)
 | 
					                shutil.move(torrents_temp, torrents)
 | 
				
			||||||
        if saved_bool:
 | 
					            if saved_bool:
 | 
				
			||||||
            shutil.move(saved_temp, saved)
 | 
					                shutil.move(saved_temp, saved)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        showMessage(Localization.localize('Storage'), Localization.localize('Storage has been cleared'), forced=True)
 | 
					            showMessage(Localization.localize('Storage'), Localization.localize('Storage has been cleared'), forced=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else:
 | 
					        else:
 | 
				
			||||||
        showMessage(Localization.localize('Storage'), Localization.localize('Does not exists'), forced=True)
 | 
					            showMessage(Localization.localize('Storage'), Localization.localize('Does not exists'), forced=True)
 | 
				
			||||||
        log('[clearStorage]: fail storage '+userStorageDirectory + os.sep)
 | 
					            log('[clearStorage]: fail storage '+userStorageDirectory + os.sep)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					        try:
 | 
				
			||||||
        DownloadDB().clear()
 | 
					            DownloadDB().clear()
 | 
				
			||||||
    except Exception, e:
 | 
					        except Exception, e:
 | 
				
			||||||
        log('[clearStorage]: DownloadDB().clear() failed. '+str(e))
 | 
					            log('[clearStorage]: DownloadDB().clear() failed. '+str(e))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True)
 | 
					        showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def sortcomma(dict, json):
 | 
					def sortcomma(dict, json):
 | 
				
			||||||
@ -136,9 +139,10 @@ def log(msg):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def debug(msg, forced=False):
 | 
					def debug(msg, forced=False):
 | 
				
			||||||
    level=xbmc.LOGDEBUG
 | 
					 | 
				
			||||||
    if getSettingAsBool('debug') and forced:
 | 
					    if getSettingAsBool('debug') and forced:
 | 
				
			||||||
        level=xbmc.LOGNOTICE
 | 
					        level=xbmc.LOGNOTICE
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        level=xbmc.LOGDEBUG
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=level )
 | 
					        xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=level )
 | 
				
			||||||
    except UnicodeEncodeError:
 | 
					    except UnicodeEncodeError:
 | 
				
			||||||
@ -1993,4 +1997,19 @@ def dump(obj):
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
            log("'%s':'%s'," % (attr, getattr(obj, attr)))
 | 
					            log("'%s':'%s'," % (attr, getattr(obj, attr)))
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def getDirectorySizeInBytes(directory):
 | 
				
			||||||
 | 
					    dir_size = 0
 | 
				
			||||||
 | 
					    for (path, dirs, files) in os.walk(directory):
 | 
				
			||||||
 | 
					        for file in files:
 | 
				
			||||||
 | 
					            filename = os.path.join(path, file)
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                dir_size += os.path.getsize(filename)
 | 
				
			||||||
 | 
					            except:
 | 
				
			||||||
 | 
					                pass
 | 
				
			||||||
 | 
					    return dir_size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def getDirectorySizeInGB(directory):
 | 
				
			||||||
 | 
					    dir_size = int(getDirectorySizeInBytes(directory)/1024/1024/1024)
 | 
				
			||||||
 | 
					    return dir_size
 | 
				
			||||||
@ -51,14 +51,18 @@
 | 
				
			|||||||
    <string id="30051">Max. connections (0 - unlimited)</string>
 | 
					    <string id="30051">Max. connections (0 - unlimited)</string>
 | 
				
			||||||
    <string id="30052">Use random ports</string>
 | 
					    <string id="30052">Use random ports</string>
 | 
				
			||||||
    <string id="30053">Port for incoming connections</string>
 | 
					    <string id="30053">Port for incoming connections</string>
 | 
				
			||||||
    <string id="30054">Pre-buffer amount before start playing, Mb</string>
 | 
					    <string id="30054">Pre-buffer amount before start playing (MB)</string>
 | 
				
			||||||
    <string id="30055">Autoplay next episode (or ask)</string>
 | 
					    <string id="30055">Autoplay next episode (or ask)</string>
 | 
				
			||||||
    <string id="30056">Device configuration</string>
 | 
					    <string id="30056">Device configuration</string>
 | 
				
			||||||
    <string id="30057">Average/Good PC</string>
 | 
					    <string id="30057">Average/Good PC</string>
 | 
				
			||||||
    <string id="30058">Below average PC/router</string>
 | 
					    <string id="30058">Below average PC/router</string>
 | 
				
			||||||
 | 
					    <string id="30059">Storage minimum size for auto clear (GB)</string>
 | 
				
			||||||
 | 
					    <string id="30060">Pause video after start</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>
 | 
				
			||||||
 | 
					    <string id="30104">Torrent-client</string>
 | 
				
			||||||
 | 
					    <string id="30105">Hentai (fine-tuning)</string>
 | 
				
			||||||
    <string id="50301">Save path</string>
 | 
					    <string id="50301">Save path</string>
 | 
				
			||||||
    <string id="50302">Call dialog</string>
 | 
					    <string id="50302">Call dialog</string>
 | 
				
			||||||
    <string id="50303">Default</string>
 | 
					    <string id="50303">Default</string>
 | 
				
			||||||
@ -80,7 +84,4 @@
 | 
				
			|||||||
    <string id="30417">Clear Storage</string>
 | 
					    <string id="30417">Clear Storage</string>
 | 
				
			||||||
    <string id="30418">Choose searcher</string>
 | 
					    <string id="30418">Choose searcher</string>
 | 
				
			||||||
    <string id="30419">You don't have external searcher. Please install it first.</string>
 | 
					    <string id="30419">You don't have external searcher. Please install it first.</string>
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</strings>
 | 
					</strings>
 | 
				
			||||||
 | 
				
			|||||||
@ -51,14 +51,18 @@
 | 
				
			|||||||
    <string id="30051">Макс. соединений (0 - безлимит)</string>
 | 
					    <string id="30051">Макс. соединений (0 - безлимит)</string>
 | 
				
			||||||
    <string id="30052">Использовать случайные порты</string>
 | 
					    <string id="30052">Использовать случайные порты</string>
 | 
				
			||||||
    <string id="30053">Порт для входящих соединений</string>
 | 
					    <string id="30053">Порт для входящих соединений</string>
 | 
				
			||||||
    <string id="30054">Загружаемый объем файла до начала просмотра, Мб</string>
 | 
					    <string id="30054">Загружаемый объем файла до начала просмотра (МБ)</string>
 | 
				
			||||||
    <string id="30055">Автоматически проиграть следующий эпизод (или предложить)</string>
 | 
					    <string id="30055">Автоматически проиграть следующий эпизод (или предложить)</string>
 | 
				
			||||||
    <string id="30056">Конфигурация устройства</string>
 | 
					    <string id="30056">Конфигурация устройства</string>
 | 
				
			||||||
    <string id="30057">Нормальный ПК</string>
 | 
					    <string id="30057">Нормальный ПК</string>
 | 
				
			||||||
    <string id="30058">Плохой ПК/роутер</string>
 | 
					    <string id="30058">Плохой ПК/роутер</string>
 | 
				
			||||||
 | 
					    <string id="30059">Минимальный размер хранилища для очистки (ГБ)</string>
 | 
				
			||||||
 | 
					    <string id="30060">Ставить паузу при старте видео</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>
 | 
				
			||||||
 | 
					    <string id="30104">Торрент-клиент</string>
 | 
				
			||||||
 | 
					    <string id="30105">Hentai (тонкая настр.)</string>
 | 
				
			||||||
    <string id="50301">Директория для сохранения файлов</string>
 | 
					    <string id="50301">Директория для сохранения файлов</string>
 | 
				
			||||||
    <string id="50302">Вызывать диалог</string>
 | 
					    <string id="50302">Вызывать диалог</string>
 | 
				
			||||||
    <string id="50303">Задать по умолчанию</string>
 | 
					    <string id="50303">Задать по умолчанию</string>
 | 
				
			||||||
 | 
				
			|||||||
@ -18,22 +18,18 @@
 | 
				
			|||||||
        <setting id="torrent_player"    type="enum"     label="30023" default="2"       lvalues="30021|30022|30046" />
 | 
					        <setting id="torrent_player"    type="enum"     label="30023" default="2"       lvalues="30021|30022|30046" />
 | 
				
			||||||
        <setting id="storage"           type="folder"   label="30004" default=""/>
 | 
					        <setting id="storage"           type="folder"   label="30004" default=""/>
 | 
				
			||||||
        <setting id="keep_files"        type="enum"     label="30008" default="1"       lvalues="30043|30044|30045"/>
 | 
					        <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,0)" />
 | 
					        <setting id="next_dl"           type="bool"     label="30013" default="true"    visible="!eq(-3,1)"/>
 | 
				
			||||||
        <setting id="next_dl"           type="bool"     label="30013" default="true"    visible="!eq(-4,1)"/>
 | 
					        <setting id="next_play"         type="bool"     label="30055" default="true"    visible="!eq(-4,1)+eq(-1,true)"/>
 | 
				
			||||||
        <setting id="next_play"         type="bool"     label="30055" default="true"    visible="!eq(-5,1)+eq(-1,true)"/>
 | 
					        <setting id="upload_limit"      type="number"   label="30010" default="0"       visible="!eq(-5,1)"/>
 | 
				
			||||||
        <setting id="upload_limit"      type="number"   label="30010" default="0"       visible="!eq(-6,1)"/>
 | 
					        <setting id="download_limit"    type="number"   label="30011" default="0"       visible="!eq(-6,1)"/>
 | 
				
			||||||
        <setting id="download_limit"    type="number"   label="30011" default="0"       visible="!eq(-7,1)"/>
 | 
					        <setting id="blank"             type="text"     label="30024" default=""        visible=" eq(-7,1)"/>
 | 
				
			||||||
        <setting id="blank"             type="text"     label="30024" default=""        visible=" eq(-8,1)"/>
 | 
					        <setting id="subs_dl"           type="bool"     label="30029" default="true"    visible="!eq(-8,1)"/>
 | 
				
			||||||
        <setting id="subs_dl"           type="bool"     label="30029" default="true"    visible="!eq(-9,1)"/>
 | 
					        <setting id="keep_seeding"      type="bool"     label="30030" default="false"   visible=" eq(-9,0)" enable="eq(-7,1)"/>
 | 
				
			||||||
        <setting id="keep_seeding"      type="bool"     label="30030" default="false"   visible=" eq(-10,0)" enable="eq(-7,1)"/>
 | 
					        <setting id="encryption"        type="bool"     label="30041" default="true"    visible="!eq(-10,1)"/>
 | 
				
			||||||
        <setting id="encryption"        type="bool"     label="30041" default="true"    visible="!eq(-11,1)"/>
 | 
					        <setting id="pre_buffer_bytes"  type="slider"   label="30054" default="25"      visible=" eq(-11,2)"  range="5,5,50" option="int"/>
 | 
				
			||||||
        <setting id="connections_limit" type="number"   label="30051" default="200"     visible=" eq(-12,2)"/>
 | 
					        <setting id="pc_config"         type="enum"     label="30056" default="0"       visible=" eq(-12,0)" lvalues="30057|30058"/>
 | 
				
			||||||
        <setting id="listen_port"       type="number"   label="30053" default="6881"    visible=" eq(-13,2)"/>
 | 
					 | 
				
			||||||
        <setting id="use_random_port"   type="bool"     label="30052" default="false"   visible=" eq(-14,2)"/>
 | 
					 | 
				
			||||||
        <setting id="pre_buffer_bytes"  type="slider"   label="30054" default="25"      visible=" eq(-15,2)"  range="5,5,50" option="int"/>
 | 
					 | 
				
			||||||
        <setting id="pc_config"         type="enum"     label="30056" default="0"       visible=" eq(-16,0)" lvalues="30057|30058"/>
 | 
					 | 
				
			||||||
    </category>
 | 
					    </category>
 | 
				
			||||||
    <category label="Torrent-client">
 | 
					    <category label="30104">
 | 
				
			||||||
        <setting id="torrent_save"                  type="enum"         label="50301" lvalues="50302|50303" default="0"/>
 | 
					        <setting id="torrent_save"                  type="enum"         label="50301" lvalues="50302|50303" default="0"/>
 | 
				
			||||||
        <setting id="torrent_dir"                   type="text"         label="50304"/>
 | 
					        <setting id="torrent_dir"                   type="text"         label="50304"/>
 | 
				
			||||||
        <setting id="torrent_replacement"           type="folder"       label="30426"/>
 | 
					        <setting id="torrent_replacement"           type="folder"       label="30426"/>
 | 
				
			||||||
@ -64,4 +60,13 @@
 | 
				
			|||||||
        <setting id="torrent_qbittorrent_login"     type="text"         label="50315" visible="eq(-20,4)" default="admin"/>
 | 
					        <setting id="torrent_qbittorrent_login"     type="text"         label="50315" visible="eq(-20,4)" default="admin"/>
 | 
				
			||||||
        <setting id="torrent_qbittorrent_password"  type="text"         label="50316" visible="eq(-21,4)" default="admin" option="hidden"/>
 | 
					        <setting id="torrent_qbittorrent_password"  type="text"         label="50316" visible="eq(-21,4)" default="admin" option="hidden"/>
 | 
				
			||||||
    </category>
 | 
					    </category>
 | 
				
			||||||
 | 
					    <category label="30105">
 | 
				
			||||||
 | 
					        <setting id="torrent_player"    type="enum"     label="30023" default="2"       lvalues="30021|30022|30046" />
 | 
				
			||||||
 | 
					        <setting id="ask_dir"           type="bool"     label="30031" default="false"/>
 | 
				
			||||||
 | 
					        <setting id="connections_limit" type="number"   label="30051" default="200"     visible=" eq(-2,2)"/>
 | 
				
			||||||
 | 
					        <setting id="use_random_port"   type="bool"     label="30052" default="false"   visible=" eq(-3,2)"/>
 | 
				
			||||||
 | 
					        <setting id="listen_port"       type="number"   label="30053" default="6881"    visible="!eq(-4,1)"/>
 | 
				
			||||||
 | 
					        <setting id="min_storage_size"  type="slider"   label="30059" default="0"       visible="!eq(-5,1)"  range="0,2,100" option="int"/>
 | 
				
			||||||
 | 
					        <setting id="pause_onplay"      type="bool"     label="30060" default="false"   visible="!eq(-6,1)"/>
 | 
				
			||||||
 | 
					    </category>
 | 
				
			||||||
</settings>
 | 
					</settings>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user