コード例 #1
0
ファイル: commands.py プロジェクト: romanvm/kodi.yatp
def show_torrent_info(info_hash):
    """
    Display current torrent info

    :param info_hash:
    :return:
    """
    torr_info = jsonrq.get_torrent_info(info_hash)
    info_dialog = xbmcgui.DialogProgress()
    info_dialog.create(torr_info['name'])
    while not info_dialog.iscanceled():
        info_dialog.update(torr_info['progress'],
                           _('state: {0}; seeds: {1}; peers: {2}').format(
                               torr_info['state'],
                               torr_info['num_seeds'],
                               torr_info['num_peers']
                           ),
                           _('size: {0}MB; DL speed: {1}KB/s; UL speed: {2}KB/s').format(
                               torr_info['size'],
                               torr_info['dl_speed'],
                               torr_info['ul_speed']
                           ),
                           _('total DL: {0}MB; total UL: {1}MB').format(
                               torr_info['total_download'],
                               torr_info['total_upload'])
                           )
        xbmc.sleep(1000)
        torr_info = jsonrq.get_torrent_info(info_hash)
コード例 #2
0
ファイル: buffering.py プロジェクト: Inter95/tutvguia
def stream_torrent(file_index):
    """
    Stream a videofile from torrent

    @param file_index:
    @return:
    """
    torrent_data = jsonrq.get_last_added_torrent()
    if file_index >= len(torrent_data['files']) or file_index < 0:
        raise IndexError('File index {0} is out of range!'.format(file_index))
    progress_dialog = xbmcgui.DialogProgress()
    progress_dialog.create(string(32014))
    jsonrq.buffer_file(file_index)
    while not (progress_dialog.iscanceled() or jsonrq.check_buffering_complete()):
        torrent_info = jsonrq.get_torrent_info(torrent_data['info_hash'])
        progress_dialog.update(jsonrq.get_buffer_percent(),
                               string(32018).format(torrent_info['total_download']),
                               string(32019).format(torrent_info['dl_speed']),
                               string(32020).format(torrent_info['num_seeds']))
        time.sleep(1.0)
    if not progress_dialog.iscanceled():
        progress_dialog.close()
        return media_url + quote(torrent_data['files'][file_index][0].replace('\\', '/').encode('utf-8'))
    else:
        jsonrq.abort_buffering()
        return ''
コード例 #3
0
ファイル: buffering.py プロジェクト: siick/kodi.yatp
def stream_torrent(file_index, info_hash):
    """
    Stream a videofile from torrent

    :param file_index:
    :param info_hash:
    :return:
    """
    files = jsonrq.get_files(info_hash)
    if file_index not in range(len(files)):
        raise IndexError('File index {0} is out of range!'.format(file_index))
    progress_dialog = xbmcgui.DialogProgress()
    progress_dialog.create(_('Buffering torrent'))
    jsonrq.buffer_file(file_index, info_hash)
    while not (progress_dialog.iscanceled() or jsonrq.check_buffering_complete()):
        torrent_info = jsonrq.get_torrent_info(info_hash)
        progress_dialog.update(jsonrq.get_buffer_percent(),
                               _('Downloaded: {0}MB. Seeds: {1}.').format(
                                   torrent_info['total_download'],
                                   torrent_info['num_seeds']
                               ),
                               _('Download speed: {0}KB/s.').format(torrent_info['dl_speed']))
        xbmc.sleep(1000)
    if not progress_dialog.iscanceled():
        progress_dialog.close()
        return media_url + quote(files[file_index][0].replace('\\', '/').encode('utf-8'))
    else:
        jsonrq.abort_buffering()
        return ''
コード例 #4
0
ファイル: actions.py プロジェクト: Inter95/tutvguia
def torrent_info(params):
    """
    Display current torrent info

    @param params:
    @return:
    """
    torr_info = jsonrq.get_torrent_info(params["info_hash"])
    info_dialog = xbmcgui.DialogProgress()
    info_dialog.create(torr_info["name"])
    while not info_dialog.iscanceled():
        info_dialog.update(
            torr_info["progress"],
            string(32011).format(torr_info["size"], torr_info["state"], torr_info["num_seeds"], torr_info["num_peers"]),
            string(32012).format(torr_info["dl_speed"], torr_info["ul_speed"]),
            string(32013).format(torr_info["total_download"], torr_info["total_upload"]),
        )
        time.sleep(1.0)
        torr_info = jsonrq.get_torrent_info(params["info_hash"])
コード例 #5
0
ファイル: commands.py プロジェクト: siick/kodi.yatp
def show_torrent_info(info_hash):
    """
    Display current torrent info

    :param info_hash:
    :return:
    """
    torr_info = jsonrq.get_torrent_info(info_hash)
    info_dialog = xbmcgui.DialogProgress()
    info_dialog.create(torr_info['name'])
    while not info_dialog.iscanceled():
        info_dialog.update(
            torr_info['progress'],
            _('state: {0}; seeds: {1}; peers: {2}').format(
                torr_info['state'], torr_info['num_seeds'],
                torr_info['num_peers']),
            _('size: {0}MB; DL speed: {1}KB/s; UL speed: {2}KB/s').format(
                torr_info['size'], torr_info['dl_speed'],
                torr_info['ul_speed']),
            _('total DL: {0}MB; total UL: {1}MB').format(
                torr_info['total_download'], torr_info['total_upload']))
        xbmc.sleep(1000)
        torr_info = jsonrq.get_torrent_info(info_hash)