Новый движок
This commit is contained in:
		
							parent
							
								
									408bd32cce
								
							
						
					
					
						commit
						eec57dbe38
					
				
							
								
								
									
										16
									
								
								addon.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								addon.py
									
									
									
									
									
								
							@ -91,16 +91,16 @@ def search(plugin, search_query, thumb=None):
 | 
			
		||||
        res_items = []
 | 
			
		||||
        for i in sorted(found_items, key=lambda x: x.seeders, reverse=True):
 | 
			
		||||
            if '2160p' in i.title:
 | 
			
		||||
                hd = '[2160p/{}] '.format(i.size)
 | 
			
		||||
                hd = f'{{2160p/{i.size}}} '
 | 
			
		||||
            elif '1080p' in i.title:
 | 
			
		||||
                hd = '[1080p/{}] '.format(i.size)
 | 
			
		||||
                hd = f'{{1080p/{i.size}}} '
 | 
			
		||||
            elif '720p' in i.title:
 | 
			
		||||
                hd = '[720p/{}] '.format(i.size)
 | 
			
		||||
                hd = f'{{720p/{i.size}}} '
 | 
			
		||||
            else:
 | 
			
		||||
                hd = ''
 | 
			
		||||
            item = Listitem.from_dict(
 | 
			
		||||
                open_torrent,
 | 
			
		||||
                '{}{} {} ({}/{})'.format(hd, i.title, i.size, i.seeders, i.leachers),
 | 
			
		||||
                f'{hd}{i.title} {i.size} ({i.seeders}/{i.leachers})',
 | 
			
		||||
                params={'url': i.url, 'cookies': i.cookies, 'referer': i.referer}
 | 
			
		||||
            )
 | 
			
		||||
            if thumb:
 | 
			
		||||
@ -129,7 +129,9 @@ def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
 | 
			
		||||
            if not tf:
 | 
			
		||||
                yield False
 | 
			
		||||
            t_full_path = store_torrent_file(tf)
 | 
			
		||||
 | 
			
		||||
            e = get_engine(t_full_path)
 | 
			
		||||
 | 
			
		||||
            files = sorted(list(filter(
 | 
			
		||||
                lambda x: x.name.startswith(path) and x.name.lower().endswith(
 | 
			
		||||
                    video_extensions), e.list_from_info(media_types=['video']))),
 | 
			
		||||
@ -151,7 +153,7 @@ def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
 | 
			
		||||
                p = f.name[len(path):].lstrip('/').split('/')
 | 
			
		||||
                if len(p) == 1:
 | 
			
		||||
                    item = Listitem.from_dict(play_file,
 | 
			
		||||
                                              '{} ({:.3f} GB)'.format(p[0], f.size / 1024.0 / 1024.0 / 1024.0),
 | 
			
		||||
                                              f'{p[0]} ({f.size / 1024.0 / 1024.0 / 1024.0:.3f} GB)',
 | 
			
		||||
                                              params={'t_full_path': t_full_path, 'f_index': f.index}
 | 
			
		||||
                                              )
 | 
			
		||||
                    item.art.local_thumb('video.png')
 | 
			
		||||
@ -169,12 +171,8 @@ def play_file(plugin, t_full_path, f_index):
 | 
			
		||||
        vl.start(f_index)
 | 
			
		||||
        return False
 | 
			
		||||
    except:
 | 
			
		||||
 | 
			
		||||
        # todo
 | 
			
		||||
        import traceback
 | 
			
		||||
        xbmc.log(f'PLAY exception: {traceback.format_exc()}')
 | 
			
		||||
        #
 | 
			
		||||
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 | 
			
		||||
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.3.2">
 | 
			
		||||
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.3.3">
 | 
			
		||||
    <requires>
 | 
			
		||||
        <import addon="xbmc.python" version="3.0.0"/>
 | 
			
		||||
        <import addon="script.module.pyrrent2http" version="1.1.1"/>
 | 
			
		||||
        <import addon="script.module.gorrent2http" version="1.2.0"/>
 | 
			
		||||
        <import addon="script.module.codequick" version="1.0.2"/>
 | 
			
		||||
        <import addon="script.module.htmlement" version="1.0.0"/>
 | 
			
		||||
        <import addon="script.module.requests" version="2.22.0"/>
 | 
			
		||||
 | 
			
		||||
@ -3,36 +3,35 @@ from .utils import get_engine, localize
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TorrentPlayer(xbmc.Player):
 | 
			
		||||
    pyrrent_engine = None
 | 
			
		||||
    gorrent_engine = None
 | 
			
		||||
    loop = None
 | 
			
		||||
    paused = False
 | 
			
		||||
 | 
			
		||||
    def onPlayBackEnded(self):
 | 
			
		||||
        self.pyrrent_engine.close()
 | 
			
		||||
        self.gorrent_engine.close()
 | 
			
		||||
        self.loop.stopped = True
 | 
			
		||||
        xbmc.Player().stop()
 | 
			
		||||
 | 
			
		||||
    def onPlayBackPaused(self):
 | 
			
		||||
        self.pyrrent_engine.pause()
 | 
			
		||||
        self.gorrent_engine.pause()
 | 
			
		||||
        self.paused = True
 | 
			
		||||
 | 
			
		||||
    def onPlayBackResumed(self):
 | 
			
		||||
        self.paused = False
 | 
			
		||||
        self.pyrrent_engine.resume()
 | 
			
		||||
        self.gorrent_engine.resume()
 | 
			
		||||
 | 
			
		||||
    def onPlayBackStopped(self):
 | 
			
		||||
        self.pyrrent_engine.close()
 | 
			
		||||
        self.gorrent_engine.close()
 | 
			
		||||
        self.loop.stopped = True
 | 
			
		||||
        xbmc.Player().stop()
 | 
			
		||||
 | 
			
		||||
    def play(self, engine, f_index):
 | 
			
		||||
        self.pyrrent_engine = engine
 | 
			
		||||
        self.pyrrent_engine.start()
 | 
			
		||||
        self.pyrrent_engine.activate_file(f_index)
 | 
			
		||||
        self.gorrent_engine = engine
 | 
			
		||||
        self.gorrent_engine.start(f_index)
 | 
			
		||||
        monitor = xbmc.Monitor()
 | 
			
		||||
        pw = xbmcgui.DialogProgress()
 | 
			
		||||
        pw.create(localize(33055), '0 Kbit/s')
 | 
			
		||||
        f_size = self.pyrrent_engine.file_status(f_index).size
 | 
			
		||||
        f_size = self.gorrent_engine.file_status(f_index).size
 | 
			
		||||
        EXPECTED_KBYTES = f_size // 3 // 1024 // 1024
 | 
			
		||||
        if EXPECTED_KBYTES > 768:
 | 
			
		||||
            EXPECTED_KBYTES = 768
 | 
			
		||||
@ -40,11 +39,11 @@ class TorrentPlayer(xbmc.Player):
 | 
			
		||||
            xbmc.sleep(500)
 | 
			
		||||
            if monitor.abortRequested() or pw.iscanceled():
 | 
			
		||||
                pw.close()
 | 
			
		||||
                self.pyrrent_engine.close()
 | 
			
		||||
                self.gorrent_engine.close()
 | 
			
		||||
                xbmc.Player().stop()
 | 
			
		||||
                self.loop.stopped = True
 | 
			
		||||
                return False
 | 
			
		||||
            status = self.pyrrent_engine.status()
 | 
			
		||||
            status = self.gorrent_engine.status()
 | 
			
		||||
            d_rate = status.download_rate
 | 
			
		||||
            # xbmc.log('*** DRATE: {}'.format(d_rate), level=xbmc.LOGNOTICE)
 | 
			
		||||
            perc = d_rate // EXPECTED_KBYTES * 100
 | 
			
		||||
@ -53,7 +52,7 @@ class TorrentPlayer(xbmc.Player):
 | 
			
		||||
            if perc == 100:
 | 
			
		||||
                pw.close()
 | 
			
		||||
                break
 | 
			
		||||
        fstat = self.pyrrent_engine.file_status(f_index)
 | 
			
		||||
        fstat = self.gorrent_engine.file_status(f_index)
 | 
			
		||||
        listitem = xbmcgui.ListItem('.'.join(fstat.name.split('/')[-1].split('.')[:-1])[:-1], path=fstat.url)
 | 
			
		||||
        xbmc.Player.play(self, fstat.url, listitem)
 | 
			
		||||
 | 
			
		||||
@ -78,7 +77,7 @@ class VideoLoop(object):
 | 
			
		||||
            if self.mediaPlayer.paused:
 | 
			
		||||
                self.statinfo.notification(
 | 
			
		||||
                    # '[{}]{}.'.format(('|' * (int(f_status.progress * 100) // 2)).ljust(50, '.'), ' ' * 100),
 | 
			
		||||
                    '[{}]'.format(('|' * (int(f_status.progress * 100) // 2)).ljust(50, '.')),
 | 
			
		||||
                    '[{}]'.format(('|' * (f_status.progress // 2)).ljust(50, '.')),
 | 
			
		||||
                    'S: {} DL: {} KB/s UL: {} KB/s'.format(status.num_seeds,
 | 
			
		||||
                                                           status.download_rate,
 | 
			
		||||
                                                           status.upload_rate),
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,7 @@ class Searcher(object):
 | 
			
		||||
                parser = HTMLement('body')
 | 
			
		||||
                parser.feed(resp.text)
 | 
			
		||||
                # todo отладка
 | 
			
		||||
                xbmc.log(f'SEARCH BODY:\n{resp.text}')
 | 
			
		||||
                # xbmc.log(f'SEARCH BODY:\n{resp.text}')
 | 
			
		||||
                #
 | 
			
		||||
                return self.process(parser.close())
 | 
			
		||||
            except:
 | 
			
		||||
 | 
			
		||||
@ -48,14 +48,14 @@ class SearchEngine(Searcher):
 | 
			
		||||
                                     data={'username': user, 'password': password, 'returnto': ''},
 | 
			
		||||
                                     cookies={}, headers=self.headers, allow_redirects=False)
 | 
			
		||||
            # todo отладка
 | 
			
		||||
            xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}')
 | 
			
		||||
            # xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}')
 | 
			
		||||
            #
 | 
			
		||||
 | 
			
		||||
            if not resp.ok:
 | 
			
		||||
                raise Exception
 | 
			
		||||
 | 
			
		||||
            # todo отладка
 | 
			
		||||
            xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}')
 | 
			
		||||
            # xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}')
 | 
			
		||||
            #
 | 
			
		||||
 | 
			
		||||
            cookies = resp.cookies
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,7 @@ class SearchEngine(Searcher):
 | 
			
		||||
                raise Exception
 | 
			
		||||
 | 
			
		||||
            # todo отладка
 | 
			
		||||
            xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}')
 | 
			
		||||
            # xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}')
 | 
			
		||||
            #
 | 
			
		||||
 | 
			
		||||
            cookies = resp.cookies
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
from codequick.support import addon_data  # @UnresolvedImport
 | 
			
		||||
from codequick.utils import urljoin_partial  # @UnresolvedImport
 | 
			
		||||
from codequick.support import addon_data
 | 
			
		||||
from codequick.utils import urljoin_partial
 | 
			
		||||
from ..settings import option
 | 
			
		||||
import xbmcgui
 | 
			
		||||
import os
 | 
			
		||||
from hashlib import sha1
 | 
			
		||||
from pyrrent2http import Engine  # @UnresolvedImport
 | 
			
		||||
from gorrent2http import Engine
 | 
			
		||||
from urllib.request import pathname2url
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -49,10 +49,10 @@ def get_engine(torrent_uri):
 | 
			
		||||
    else:
 | 
			
		||||
        proxy = None
 | 
			
		||||
    return Engine(uri=file_url(torrent_uri), download_path=storage_download_dir,
 | 
			
		||||
                  encryption=1, keep_complete=False, keep_incomplete=False,
 | 
			
		||||
                  encryption=1, keep_files=False,
 | 
			
		||||
                  dht_routers=["router.bittorrent.com:6881", "router.utorrent.com:6881"], use_random_port=False,
 | 
			
		||||
                  listen_port=6881,
 | 
			
		||||
                  user_agent='', enable_dht=True, proxy=proxy)
 | 
			
		||||
                  user_agent='', enable_dht=True, proxy=proxy, debug_alerts=False)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
while not option['storage_dir']:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user