Exemplo n.º 1
0
def buffer_torrent(torrent, file_index=None):
    """
    Buffer a torrent and resolve a playable path from it

    :param torrent: str - magnet link or .torrent file URL
    :return:
    """
    torrent_data = add_torrent(torrent, False)
    if torrent_data is not None:
        if file_index is None or file_index == 'dialog':
            file_index = select_file(torrent_data, file_index == 'dialog')
        if file_index is None:
            jsonrq.remove_torrent(torrent_data['info_hash'], True)
            xbmcgui.Dialog().notification(addon.id, _('No videofiles to play.'), addon.icon, 3000)
        elif file_index >= 0:
            url = stream_torrent(file_index, torrent_data['info_hash'])
            if url:
                return url
        else:
            xbmcgui.Dialog().notification(addon.id, _('No video is selected.'), addon.icon, 3000)
    if not (jsonrq.check_torrent_added() and jsonrq.check_buffering_complete()):
        xbmcgui.Dialog().notification(addon.id, _('Playback cancelled.'), addon.icon, 3000)
    return ''
Exemplo n.º 2
0
def buffer_torrent(torrent, file_index=None):
    """
    Buffer a torrent and resolve a playable path from it

    @param torrent: str - magnet link or .torrent file URL
    @return:
    """
    torrent_data = add_torrent(torrent)
    if torrent_data is not None:
        if file_index is None or file_index == 'dialog':
            file_index = select_file(torrent_data, file_index == 'dialog')
        if file_index is None:
            jsonrq.remove_torrent(torrent_data['info_hash'], True)
            xbmcgui.Dialog().notification(addon.id, string(32022), addon.icon, 3000)
        elif file_index >= 0:
            url = stream_torrent(file_index)
            if url:
                return url
        else:
            xbmcgui.Dialog().notification(addon.id, string(32021), addon.icon, 3000)
    if not (jsonrq.check_torrent_added() and jsonrq.check_buffering_complete()):
        xbmcgui.Dialog().notification(addon.id, string(32023), addon.icon, 3000)
    return ''
Exemplo n.º 3
0
                               torr_info['total_download'],
                               torr_info['total_upload'])
                           )
        xbmc.sleep(1000)
        torr_info = jsonrq.get_torrent_info(info_hash)


if __name__ == '__main__':
    if sys.argv[1] == 'pause':
        jsonrq.pause_torrent(sys.argv[2])
    elif sys.argv[1] == 'resume':
        jsonrq.resume_torrent(sys.argv[2])
    elif sys.argv[1] == 'delete' and xbmcgui.Dialog().yesno(
            _('Confirm delete'),
            _('Do you really want to delete the torrent?')):
        jsonrq.remove_torrent(sys.argv[2], False)
    elif sys.argv[1] == 'delete_with_files'and xbmcgui.Dialog().yesno(
            _('Confirm delete'),
            _('Do you really want to delete the torrent with files?'),
            _('Warning: The files will be deleted permanently!')):
        jsonrq.remove_torrent(sys.argv[2], True)
    elif sys.argv[1] == 'pause_all':
        jsonrq.pause_all()
    elif sys.argv[1] == 'resume_all':
        jsonrq.resume_all()
    elif sys.argv[1] == 'show_info':
        show_torrent_info(sys.argv[2])
    elif sys.argv[1] == 'restore_finished':
        jsonrq.restore_finished(sys.argv[2])
    else:
        addon.log_debug('Command cancelled or invalid command: {0}'.format(sys.argv[1]))
Exemplo n.º 4
0
                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)


if __name__ == '__main__':
    if sys.argv[1] == 'pause':
        jsonrq.pause_torrent(sys.argv[2])
    elif sys.argv[1] == 'resume':
        jsonrq.resume_torrent(sys.argv[2])
    elif sys.argv[1] == 'delete' and xbmcgui.Dialog().yesno(
            _('Confirm delete'),
            _('Do you really want to delete the torrent?')):
        jsonrq.remove_torrent(sys.argv[2], False)
    elif sys.argv[1] == 'delete_with_files' and xbmcgui.Dialog().yesno(
            _('Confirm delete'),
            _('Do you really want to delete the torrent with files?'),
            _('Warning: The files will be deleted permanently!')):
        jsonrq.remove_torrent(sys.argv[2], True)
    elif sys.argv[1] == 'pause_all':
        jsonrq.pause_all()
    elif sys.argv[1] == 'resume_all':
        jsonrq.resume_all()
    elif sys.argv[1] == 'show_info':
        show_torrent_info(sys.argv[2])
    elif sys.argv[1] == 'restore_finished':
        jsonrq.restore_finished(sys.argv[2])
    else:
        addon.log_debug('Command cancelled or invalid command: {0}'.format(