Merge branch 'master' of https://github.com/DiMartinoXBMC/plugin.video.torrenter into DiMartinoXBMC-master

pull/8/head^2
inpos 2016-03-20 13:45:14 +03:00
commit f921d242dc
3 changed files with 31 additions and 51 deletions

View File

@ -306,7 +306,7 @@ class AnteoPlayer(xbmc.Player):
if not self.next_play: if not self.next_play:
xbmc.sleep(3000) xbmc.sleep(3000)
if not xbmcgui.Dialog().yesno( if not xbmcgui.Dialog().yesno(
self.localize('Torrent2HTTP'), self.localize('[%sPlayer v%s] ' % (author, __version__)),
self.localize('Would you like to play next episode?')): self.localize('Would you like to play next episode?')):
break break
self.contentId = self.next_contentId self.contentId = self.next_contentId
@ -386,7 +386,7 @@ class AnteoPlayer(xbmc.Player):
dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"] dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"]
user_agent = 'uTorrent/2200(24683)' user_agent = 'uTorrent/2200(24683)'
self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024 self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024
showMessage('[%sPlayer v%s] ' % (author, __version__), self.localize('Please Wait')) #showMessage('[%sPlayer v%s] ' % (author, __version__), self.localize('Please Wait'))
self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory, self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory,
connections_limit=connections_limit, download_kbps=download_limit, upload_kbps=upload_limit, connections_limit=connections_limit, download_kbps=download_limit, upload_kbps=upload_limit,

View File

@ -156,44 +156,6 @@ class InposLoader:
torrent = Libtorrent(self.storageDirectory, self.torrentFile) torrent = Libtorrent(self.storageDirectory, self.torrentFile)
return torrent.getContentList() return torrent.getContentList()
'''def getContentList_engine(self):
self.setup_engine()
files = []
filelist = []
try:
self.engine.start()
#media_types=[MediaType.VIDEO, MediaType.AUDIO, MediaType.SUBTITLES, MediaType.UNKNOWN]
iterator = 0
text = Localization.localize('Magnet-link is converting') if self.magnetLink\
else Localization.localize('Opening torrent file')
while not files and not xbmc.abortRequested and iterator < 100:
files = self.engine.list()
self.engine.check_torrent_error()
if iterator==4:
progressBar = xbmcgui.DialogProgress()
progressBar.create(Localization.localize('Please Wait'),
Localization.localize('Magnet-link is converting'))
elif iterator>4:
progressBar.update(iterator, Localization.localize('Please Wait'),text+'.' * (iterator % 4), ' ')
if progressBar.iscanceled():
progressBar.update(0)
progressBar.close()
return []
xbmc.sleep(500)
iterator += 1
for fs in files:
stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
'offset': fs.offset}
filelist.append(stringdata)
except:
import traceback
log(traceback.format_exc())
finally:
self.engine.close()
return filelist'''
def saveTorrent(self, torrentUrl): def saveTorrent(self, torrentUrl):
#if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl): #if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl):
if re.match("^magnet\:.+$", torrentUrl): if re.match("^magnet\:.+$", torrentUrl):
@ -286,9 +248,15 @@ class InposPlayer(xbmc.Player):
try: try:
self.engine.start() self.engine.start()
self.setup_nextep() self.setup_nextep()
<<<<<<< HEAD
while True: while True:
self.engine.activate_file(self.contentId) self.engine.activate_file(self.contentId)
if self.buffer(): if self.buffer():
=======
self.engine.activate_file(self.contentId)
if self.buffer():
while True:
>>>>>>> 337de1c95f0872a9223a8008698caf9099137ff7
log('['+author+'Player]: ************************************* GOING LOOP') log('['+author+'Player]: ************************************* GOING LOOP')
if self.setup_play(): if self.setup_play():
self.setup_subs() self.setup_subs()
@ -302,7 +270,7 @@ class InposPlayer(xbmc.Player):
if not self.next_play: if not self.next_play:
xbmc.sleep(3000) xbmc.sleep(3000)
if not xbmcgui.Dialog().yesno( if not xbmcgui.Dialog().yesno(
self.localize('Torrent2HTTP'), self.localize('[%sPlayer v%s] ' % (author, __version__)),
self.localize('Would you like to play next episode?')): self.localize('Would you like to play next episode?')):
break break
self.contentId = self.next_contentId self.contentId = self.next_contentId
@ -382,6 +350,7 @@ class InposPlayer(xbmc.Player):
dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"] dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"]
user_agent = 'uTorrent/2200(24683)' user_agent = 'uTorrent/2200(24683)'
self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024 self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024
if self.__settings__.getSetting('debug') == 'true':
showMessage('[%sPlayer v%s] ' % (author, __version__), self.localize('Please Wait')) showMessage('[%sPlayer v%s] ' % (author, __version__), self.localize('Please Wait'))
self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory, self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory,
@ -477,6 +446,7 @@ class InposPlayer(xbmc.Player):
label = os.path.basename(file_status.name) label = os.path.basename(file_status.name)
self.basename = label self.basename = label
self.seeding_run = False self.seeding_run = False
self.next_dling = False
listitem = xbmcgui.ListItem(label, path=url) listitem = xbmcgui.ListItem(label, path=url)
if self.next_dl: if self.next_dl:
@ -511,6 +481,7 @@ class InposPlayer(xbmc.Player):
if thumbnail: if thumbnail:
listitem.setThumbnailImage(urllib.unquote_plus(thumbnail)) listitem.setThumbnailImage(urllib.unquote_plus(thumbnail))
self.display_name = label self.display_name = label
log(self.display_name)
player = xbmc.Player() player = xbmc.Player()
player.play(url, listitem) player.play(url, listitem)
@ -552,7 +523,7 @@ class InposPlayer(xbmc.Player):
with nested(self.attach(overlay.show, self.on_playback_paused), with nested(self.attach(overlay.show, self.on_playback_paused),
self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)): self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)):
while not xbmc.abortRequested and self.isPlaying(): while not xbmc.abortRequested and self.isPlaying():
#self.print_fulldebug() self.print_fulldebug()
status = self.engine.status() status = self.engine.status()
file_status = self.engine.file_status(self.contentId) file_status = self.engine.file_status(self.contentId)
self.watchedTime = xbmc.Player().getTime() self.watchedTime = xbmc.Player().getTime()
@ -572,11 +543,16 @@ class InposPlayer(xbmc.Player):
xbmc.Player().pause() xbmc.Player().pause()
xbmc.sleep(1000) xbmc.sleep(1000)
#if not self.seeding_run and self.iterator == 100 and self.seeding: if self.iterator == 100 and self.next_dl and not self.next_dling and isinstance(self.next_contentId,
#self.seeding_run = True int) and self.next_contentId != False:
#self.seed(self.contentId) self.engine.activate_file(self.next_contentId)
#self.seeding_status = True showMessage(self.localize('Torrent Downloading'),
# xbmc.sleep(7000) self.localize('Starting download next episode!'), forced=True)
log('[loop]: next_contentId '+str(self.next_contentId)+str(isinstance(self.next_contentId, int)))
file_status = self.engine.file_status(self.next_contentId)
self.basename = self.display_name = os.path.basename(file_status.name)
self.next_dling = True
def onPlayBackStarted(self): def onPlayBackStarted(self):
for f in self.on_playback_started: for f in self.on_playback_started:
@ -608,7 +584,7 @@ class InposPlayer(xbmc.Player):
def _get_status_lines(self, s, f): def _get_status_lines(self, s, f):
return [ return [
encode_msg(self.display_name), self.display_name.encode('utf-8'),
"%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state])), "%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state])),
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s'), "D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s'),
s.upload_rate, self.localize('kb/s'), s.upload_rate, self.localize('kb/s'),

View File

@ -2053,7 +2053,11 @@ def uri2path(uri):
def localize_path(path): def localize_path(path):
import chardet import chardet
if not isinstance(path, unicode): path = path.decode(chardet.detect(path)['encoding']) if not isinstance(path, unicode):
try:
path = path.decode(chardet.detect(path).get('encoding') or 'utf-8')
except:
pass
if not sys.platform.startswith('win'): if not sys.platform.startswith('win'):
path = encode_msg(path) path = encode_msg(path)
return path return path