Exemplo n.º 1
0
def test_to_file(torr_test_file):
    t0 = Torrent({})

    with pytest.raises(TorrentError):
        t0.to_file()

    t1 = Torrent.from_file(torr_test_file)
    fpath = join(mkdtemp(), str(uuid4()))
    t1.to_file(fpath)

    t2 = Torrent.from_file(fpath)
    assert t1._struct == t2._struct
Exemplo n.º 2
0
def test_to_file():
    t0 = Torrent({})

    with pytest.raises(TorrentError):
        t0.to_file()

    t1 = Torrent.from_file(FPATH_TORRENT_SIMPLE)
    fpath = join(mkdtemp(), str(uuid4()))
    t1.to_file(fpath)

    t2 = Torrent.from_file(fpath)
    assert t1._struct == t2._struct
Exemplo n.º 3
0
def test_to_file():
    t0 = Torrent({})

    with pytest.raises(TorrentError):
        t0.to_file()

    t1 = Torrent.from_file(FPATH_TORRENT_SIMPLE)
    fpath = join(mkdtemp(), str(uuid4()))
    t1.to_file(fpath)

    t2 = Torrent.from_file(fpath)
    assert t1._struct == t2._struct
Exemplo n.º 4
0
def test_str(torr_test_file):
    """ Tests Torrent.__str__ method """
    t = Torrent.from_file(torr_test_file)
    assert str(t) == 'Torrent: root.txt'

    t.name = 'Мой торрент'
    assert str(t) == 'Torrent: Мой торрент'
Exemplo n.º 5
0
def transfer_files(filename, base_folder):
    if filename.find(".") != -1:
        ext = get_extension(filename)
        # torrent file check
        # watch torrent which will be checked when processing directories
        if (ext == ".torrent"):
            torrent_folder = Torrent.from_file(base_folder + "/" +
                                               filename).name.encode('ascii')
            # convert name property of torrent file to a normal string
            global folder_torrent
            folder_torrent.append(torrent_folder)
        folder = get_folder(ext)
        # print "folder = " + folder
        if folder != "NA":
            folder_path = base_folder + "/" + folder
            # check if a sorting folder directory exists
            if os.path.exists(folder_path) == False:
                os.mkdir(folder_path)
            #move file to sorting folder
            try:
                shutil.move(base_folder + "/" + filename, folder_path)
                global move_count
                move_count += 1
                # print "moved " + filename + " to " + folder
            except:
                print("\nERROR: File transfer error: " + filename + "\n")
Exemplo n.º 6
0
def getHashinfor():
    dir = "/home/pyHome/download/"
    file_path = dir+"down.torrent"
    file_name = ""
    #print file_path
    my_torrent = None
    my_torrent = Torrent.from_file(file_path)
    #print type(my_torrent)
    print my_torrent.magnet_link
    files = my_torrent.files
    con = getConnect()
    print files
    print "------------------------------------------"
    try:
        uuid1 = str(uuid.uuid1())
        for file in files:
            sqlStr = "insert into torrent_info (name, size, mangent, fkey) VALUES('v1', v2, 'v3', 'v4')"
            name = file[0].replace("'", "\'");
            sqlStr = sqlStr.replace("v1", name)
            sqlStr = sqlStr.replace("v2", str(file[1]))
            sqlStr = sqlStr.replace("v3", "#")
            sqlStr = sqlStr.replace("v4", uuid1)
            print sqlStr
            cur = con.cursor()
            cur.execute(sqlStr)
            con.commit()
    finally:
        cur.close()
Exemplo n.º 7
0
def test_str():
    """ Tests Torrent.__str__ method """
    t = Torrent.from_file(FPATH_TORRENT_SIMPLE)
    assert str(t) == 'Torrent: root.txt'

    t.name = 'Мой торрент'
    assert str(t) == 'Torrent: Мой торрент'
Exemplo n.º 8
0
def monitor_update(TorrentPath, value, remove=False):
    elementum_setting, elementum_host, TorrentPath = setting()
    json = jsontools.load(open(monitor, "r").read())
    Monitor = json['monitor']
    info = Torrent.from_file(filetools.join(TorrentPath, value + '.torrent'))
    path = xbmc.translatePath(config.get_setting('downloadlistpath'))

    if not value in Monitor:
        Monitor[value]={}
        Monitor[value]['name'] = info.name
        Monitor[value]['size'] = info.total_size
        File = find_file(value)
        Monitor[value]['file'] = File
        json = jsontools.dump(json)
        filetools.write(monitor, json, silent=True)

        backupFilename = jsontools.load(open(filetools.join(path, File), "r").read())['downloadFilename']
        jsontools.update_node(value, File, 'TorrentName', path, silent=True)
        jsontools.update_node(info.total_size, File, 'downloadSize', path, silent=True)
        jsontools.update_node(backupFilename, File, 'backupFilename', path, silent=True)
        jsontools.update_node(info.name, File, 'downloadFilename', path, silent=True)

    elif remove:
        Monitor.pop(value)
        jsontools.dump(json)
        filetools.write(monitor, jsontools.dump(json), silent=True)

    if len(Monitor) == 0: set_elementum()
Exemplo n.º 9
0
def test_str():
    """ Tests Torrent.__str__ method """
    t = Torrent.from_file(FPATH_TORRENT_SIMPLE)
    assert str(t) == 'Torrent: root.txt'

    t.name = 'Мой торрент'
    assert str(t) == 'Torrent: Мой торрент'
Exemplo n.º 10
0
def test_getters_simple():
    t = Torrent.from_file(FPATH_TORRENT_SIMPLE)

    assert t._filepath == FPATH_TORRENT_SIMPLE

    assert t.created_by == 'Transmission/2.84 (14307)'

    files = t.files
    assert len(files) == 1
    assert files[0].name == files[0][0] == 'root.txt'
    assert files[0].length == 4

    assert t.total_size == 4
    assert t.name == u'root.txt'
    assert t.announce_urls == [['udp://123.123.123.123']]
    assert t.creation_date.isoformat() == '2015-10-21T17:40:05'
    assert t.comment is None

    hash_expected = '238967c8417cc6ccc378df16687d1958277f270b'
    assert t.info_hash == hash_expected

    magnet = t.magnet_link
    assert hash_expected in magnet
    assert 'btih' in magnet
    assert 'magnet:' in magnet
Exemplo n.º 11
0
def test_getters_dir():
    t = Torrent.from_file(FPATH_TORRENT_WITH_DIR)

    assert t._filepath == FPATH_TORRENT_WITH_DIR

    assert t.created_by == 'Transmission/2.84 (14307)'
    assert t.files == [(normpath('torrtest/root.txt'), 4),
                       (normpath('torrtest/sub1/sub11.txt'), 4),
                       (normpath(u'torrtest/sub1/sub2/кириллица.txt'), 11),
                       (normpath('torrtest/sub1/sub2/sub22.txt'), 4)]
    assert t.total_size == 23
    assert t.announce_urls == [[
        'http://track1.org/1/', 'http://track2.org/2/'
    ]]
    assert t.creation_date.isoformat() == '2015-10-25T09:42:04'
    assert t.comment == u'примечание'

    hash_expected = 'c815be93f20bf8b12fed14bee35c14b19b1d1984'
    assert t.info_hash == hash_expected

    magnet = t.magnet_link
    assert hash_expected in magnet
    assert 'btih' in magnet
    assert 'magnet:' in magnet

    magnet = t.get_magnet(detailed=True)
    assert (
        magnet ==
        'magnet:?xt=urn:btih:c815be93f20bf8b12fed14bee35c14b19b1d1984'
        '&tr=http%3A%2F%2Ftrack1.org%2F1%2F&tr=http%3A%2F%2Ftrack2.org%2F2%2F')
Exemplo n.º 12
0
def test_getters_simple():
    t = Torrent.from_file(FPATH_TORRENT_SIMPLE)

    assert t._filepath == FPATH_TORRENT_SIMPLE

    assert t.created_by == 'Transmission/2.84 (14307)'
    assert t.files == [('root.txt', 4)]
    assert t.total_size == 4
    assert t.name == u'root.txt'
    assert t.announce_urls == [['udp://123.123.123.123']]
    assert t.creation_date.isoformat() == '2015-10-21T17:40:05'
    assert t.comment is None

    hash_expected = '238967c8417cc6ccc378df16687d1958277f270b'
    assert t.info_hash == hash_expected

    magnet = t.magnet_link
    assert hash_expected in magnet
    assert 'btih' in magnet
    assert 'magnet:' in magnet
Exemplo n.º 13
0
def generatingTorrent():
    remoteTempTorrent()
    if not os.path.exists(f'torrents/{request.args.get("id")}.torrent'):
        return "torrent unavailable"
    my_torrent = Torrent.from_file(
        f'torrents/{request.args.get("id")}.torrent')
    # changing passkey for one transmitted as parameter by user
    newUrlTracker = re.sub("[a-zA-Z0-9]{32}", request.args.get("passkey"),
                           ((my_torrent.announce_urls[0])[0]))
    my_torrent.announce_urls = newUrlTracker
    # write it in temp dir for more clarity
    my_torrent.to_file(
        f'torrents/tmp/{request.args.get("id")}.{request.args.get("passkey")}.torrent'
    )
    # send torrent file
    return send_file(
        f'torrents/tmp/{request.args.get("id")}.{request.args.get("passkey")}.torrent',
        as_attachment=True,
        attachment_filename=(my_torrent.name + ".torrent"),
        mimetype='application/x-bittorrent')
Exemplo n.º 14
0
def get_torrent(infohash):
    downloadUrl = "http://torcache.net/torrent/value1.torrent"
    downloadUrl = downloadUrl.replace('value1', infohash)
    dirHome = "/home/pyHome/download/"
    downloadFile = dirHome+infohash+".torrent"
    #print downloadFile
    #os.chdir(dirHome)
    try:
        send_headers = {
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36',
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
        }
        req = urllib2.Request(downloadUrl,headers=send_headers)
        file = urllib2.urlopen(req).read()
        open(downloadFile, "w").write(file)
        my_torrent = Torrent.from_file(downloadFile)
        print my_torrent.files
        
    except NameError, msg:
	    print msg
Exemplo n.º 15
0
def create_seek_data(seed_file, torDir):
    if not os.path.exists(seed_file):
        print('invalid torrent file')
        return

    from torrentool.api import Torrent
    torrent_info = Torrent.from_file(seed_file)

    print('seek for %s' % torrent_info.name)
    for it in torrent_info.files:
        fit = os.path.join('/tmp', it[0])
        pname, fname = os.path.split(fit)
        if not os.path.exists(pname):
            os.makedirs(pname)
        with open(fit, 'wb') as f:
            f.seek(max(0, it[1] - 1))
            f.write(b'\x00')

    entry = os.path.join('/tmp', torrent_info.name)
    os.system('rsync -avhP --size-only --bwlimit=32000 "%s" "%s"' %
              (entry, torDir))
Exemplo n.º 16
0
def vuze_done_move():
    res = os.popen("ps aux | grep '[%s]%s'" %
                   (vuzescpt[0], vuzescpt[1:])).readlines()
    if len(res) != 0:
        return

    L = []
    for it in os.listdir(vuzetodo):
        if not it.endswith('.torrent') or it.startswith('.'):
            continue

        seed_file = os.path.join(vuzetodo, it)
        torrent_info = Torrent.from_file(seed_file)
        tpath = os.path.join('/Volumes/Store/Downloads/complete',
                             torrent_info.name)
        if torrent_info.announce_urls[0][0].find('totheglory.im') < 0:
            continue

        all_exists = True  # 避免重复下载了已有的种子,再次传输到主磁盘
        for fit in torrent_info.files:
            if not os.path.exists(
                    os.path.join('/Volumes/Googol/Torrent', fit[0])):
                all_exists = False
                break
        if not all_exists and os.path.exists(tpath):
            print('add', torrent_info.name)
            L.append(
                (tpath, seed_file, torrent_info.total_size, torrent_info.name))
            torrent_info.announce_urls = []
            torrent_info.to_file(
                os.path.join('/Volumes/Store/Downloads/cheat',
                             torrent_info.name + '.torrent'))

    if len(L) > 0:
        f = open('/tmp/vuzetext', 'w', encoding='utf-8')
        for it in L:
            str = '%s###%s###%d###%s\n' % (it[0], it[1], it[2], it[3])
            f.write(str)
        f.close()
        os.system('open -ga iTerm %s' % vuzescpt)
Exemplo n.º 17
0
def generatingTorrent():
    remoteTempTorrent()
    if not (os.path.isfile(os.getcwd() + "/blackhole/torrents/" +
                           request.args.get("id") + ".torrent")):
        return "torrent unavailable"
    # grab torrent file matching id provided
    my_torrent = Torrent.from_file(os.getcwd() + "/blackhole/torrents/" +
                                   request.args.get("id") + ".torrent")
    # changing passkey for one transmitted as parameter by user
    newUrlTracker = re.sub("[a-zA-Z0-9]{32}", request.args.get("passkey"),
                           ((my_torrent.announce_urls[0])[0]))
    my_torrent.announce_urls = newUrlTracker
    # write it in temp dir for more clarity
    my_torrent.to_file(os.getcwd() + "/blackhole/torrents/tmp/" +
                       request.args.get("id") + request.args.get("passkey") +
                       ".torrent")
    # send torrent file
    return send_file(os.getcwd() + "/blackhole/torrents/tmp/" +
                     request.args.get("id") + request.args.get("passkey") +
                     ".torrent",
                     as_attachment=True,
                     attachment_filename=(my_torrent.name + ".torrent"),
                     mimetype='application/x-bittorrent')
Exemplo n.º 18
0
def test_getters_dir():
    t = Torrent.from_file(FPATH_TORRENT_WITH_DIR)

    assert t._filepath == FPATH_TORRENT_WITH_DIR

    assert t.created_by == 'Transmission/2.84 (14307)'
    assert t.files == [
        (normpath('torrtest/root.txt'), 4),
        (normpath('torrtest/sub1/sub11.txt'), 4),
        (normpath(u'torrtest/sub1/sub2/кириллица.txt'), 11),
        (normpath('torrtest/sub1/sub2/sub22.txt'), 4)
    ]
    assert t.total_size == 23
    assert t.announce_urls == [['http://track1.org/1/', 'http://track2.org/2/']]
    assert t.creation_date.isoformat() == '2015-10-25T09:42:04'
    assert t.comment == u'примечание'

    hash_expected = 'c815be93f20bf8b12fed14bee35c14b19b1d1984'
    assert t.info_hash == hash_expected

    magnet = t.magnet_link
    assert hash_expected in magnet
    assert 'btih' in magnet
    assert 'magnet:' in magnet
import os
from torrentool.api import Torrent

torrents_path = input(
    "Enter torrent folder path:")  # Path to folder containing torrent files
if not torrents_path.endswith("\\"):
    torrents_path = torrents_path + "\\"

for subdir, dirs, files in os.walk(torrents_path):
    for filename in files:
        filepath = subdir + os.sep + filename
        # Only rename files ended with .torrent extension
        if filepath.endswith(".torrent"):
            torrent = Torrent.from_file(filepath)
            torrent_name = torrent.name
            if not os.path.isfile(torrents_path + torrent_name + ".torrent"):
                os.rename(filepath, torrents_path + torrent_name + ".torrent")
            else:  # In case duplicate torrent file name
                # If ABC.torrent exists, rename to ABC 1.torrent, ABC 2.torrent, etc.
                counter = 1
                while os.path.isfile(torrents_path + torrent_name + " " +
                                     str(counter) + ".torrent"):
                    counter += 1
                os.rename(
                    filepath, torrents_path + torrent_name + " " +
                    str(counter) + ".torrent")

print("Rename complete")
Exemplo n.º 20
0
#creating torrent
from torrentool.api import Torrent
import os
from qbittorrentapi import Client
import requests
import subprocess
import sys

filename = input("please enter the file name to be seeded ")

#filename="a1.mkv"
#creating torrent for sharing
os.system("py3createtorrent " + filename)
#seeding and DHT formation
client = Client(host="http://192.168.1.5:8080/",
                username='******',
                password='******')
tor = client.torrents.info()
#client.torrents_add(torrent_files = '/home/silver/Desktop/torflix/seed/a1.mkv.torrent')
#Added the file file to the torrent list

client.torrents_add(torrent_files=filename + '.torrent')

print("successfully added the torrent and the magnet link for sharing is:")
my_torrent = Torrent.from_file(filename + '.torrent')
magb = my_torrent.magnet_link
print(magb)
Exemplo n.º 21
0
def get_hash_file(path):
    tr = Torrent.from_file(path)
    mgt = tr.magnet_link
    return get_hash_magnet(mgt)
Exemplo n.º 22
0
def get_torrents_in_dir(path):
    torrent_files = (fn for fn in os.listdir(path) if fn.endswith('.torrent'))
    return (Torrent.from_file(name) for name in torrent_files)
Exemplo n.º 23
0
        limit_size=currentValue
    elif currentArgument in ("-t","--sort"):
        sort_type=currentValue

limit=int(re.findall(r'\d+', limit_size)[0])
divisor=1
if "TB" in limit_size.upper():
    divisor=1000
folder_list=[]
size = 0
temp=[]
files_list=[]

print("Script starting... getting all torrents in directory")
for f in os.listdir(input_directory):
    my_torrent = Torrent.from_file(f'{input_directory}/{f}')
    new_file = {"name":f,"size":my_torrent.total_size}
    files_list.append(new_file)

if sort_type == "1":
    print("Sorting Torrents by Size...")
    files_list=sorted(files_list, key = lambda i: i['size'],reverse=True)
else:
    print("Sorting Torrents by Name...")
    files_list=sorted(files_list, key = lambda i: i['name'])


print("Splitting torrents by size...")
for f in files_list:
    if((size+(f['size']/1073741824))/divisor>limit):
        folder_list.append(temp)
Exemplo n.º 24
0
def check_tg_Info(data):
    xtree = html.fromstring(data)
    usize = xtree.xpath(
        '/html/body/table[2]/tr/td/table/tr/td[1]/span/font[4]/a')[0]
    usize = float(usize.text[:-3]) * (1.0 if usize.text[-2] == "T" else 0.001)
    res = exsql("insert into ttg (logtime, upsizeT) values ('%s', '%f')" %
                (com.nowstr, usize))
    res = exsql("select dayup, hourup from ttg order by logtime DESC limit 1")
    print('usize      : %.3f TB  %s GB  %s GB' % (usize, res[0][0], res[0][1]))

    dsize = xtree.xpath(
        '/html/body/table[2]/tr/td/table/tr/td[1]/span/font[6]/a')[0]
    dsize = float(dsize.text[:-3]) * (1.0 if dsize.text[-2] == "T" else 0.001)
    print('dsize      : %.3f TB' % dsize)

    share = xtree.xpath(
        '/html/body/table[2]/tr/td/table/tr/td[1]/span/font[2]')
    share = float(share[0].text)
    print('share      : %.3f' % share)

    jifen = xtree.xpath('/html/body/table[2]/tr/td/table/tr/td[1]/a[1]')
    jifen = float(jifen[0].text)
    print('jifen      : %.2f' % jifen)

    torrent_list = []
    free_count = 0
    serial_number = 0
    for t in xtree.xpath('//*[@id="torrent_table"]/tr')[1:]:
        serial_number += 1
        try:
            name = t.xpath(
                './td[2]/div[1]/span/a/img[@class="report"]//@torrentname')[
                    0]  #
            name = name.strip().replace(' ', '.').replace('/', '.').replace(
                '#', '').replace(':', '')
            name = name.replace('`', '')

            free = t.xpath('./td[2]/div[1]/img[@alt="free"]/@alt') == ['free']
            hrun = t.xpath(
                './td[2]/div[1]/img[@title="Hit and Run"]/@title') == [
                    'Hit and Run'
                ]
            free_count += 1 if free else 0

            date = t.xpath('./td[5]/nobr')[0].text
            stmp = t.xpath('./td[5]/nobr')[0].text_content().replace(
                date, date + ' ')
            tsec = time.mktime(time.strptime(stmp, "%Y-%m-%d %H:%M:%S"))

            snum, dnum = t.xpath('./td[9]')[0].text_content().replace(
                '\n', '').split(' ')[0].split('/')
            snum = int(snum)
            dnum = int(dnum)

            href = t.xpath('./td[2]/div[2]/span/a[@class="dl_a"]/@href')[0]
            href = com.tgserver + href

            size = t.xpath('./td[7]/text()')
            size = float(size[0]) * (1.0 if size[-1] == 'GB' else 0.001)
        except Exception as e:
            print('             parse error')
            return
        if checkKeys(name,
                     com.blocktg) or com.nowsec - tsec > 3600:  # 跳过黑名单和太久种子
            continue

        if t.get('style') in ['', None]:
            if checkKeys(name, com.favortg) and com.nowsec - tsec < 7200:
                torrent_list.append((name, href))
                continue
            if name.find('-WiKi') > 0:
                torrent_list.append((name, href))
                continue
            if serial_number <= 3:
                torrent_list.append((name, href))
                continue

            if not free:  #or hrun
                continue
            if size < 5:
                torrent_list.append((name, href))
                continue
            if size < 10 and dnum > 6 and com.nowsec - tsec < 1000:  # int(size)
                torrent_list.append((name, href))
                continue
            if size < 15 and dnum > 10 and com.nowsec - tsec < 1500:
                torrent_list.append((name, href))
                continue
            if size < 60 and dnum > 25 and com.nowsec - tsec < 1800:
                torrent_list.append((name, href))
                continue

    if free_count > 40:
        print('too many free seeds')
        return

    for it in torrent_list:
        tname = it[0]
        thref = it[1]
        seed_file = os.path.join('/tmp', tname + '.torrent')
        if not os.path.exists(seed_file):
            print('fetchg     : %s' % tname)
            seed_data = get(thref, com.tgcook)
            if seed_data is None:
                continue
            with open(seed_file, 'wb') as f:
                f.write(seed_data)

        from torrentool.api import Torrent
        torrent_info = Torrent.from_file(seed_file)
        exist_size = 0
        total_size = torrent_info.total_size
        for it in torrent_info.files:
            if os.path.exists(os.path.join('/Volumes/Googol/Torrent', it[0])):
                print('exists ', it[0])
                exist_size += it[1]
        if exist_size / total_size > 0.6:
            os.system('cp -f "%s" "%s"' % (seed_file, ut_watch))
        elif total_size <= 10 * 1000000000:  #and hour >= 8
            os.system('cp -f "%s" "%s"' % (seed_file, qt_watch))
        else:
            os.system('cp -f "%s" "%s"' % (seed_file, qt_watch))
Exemplo n.º 25
0
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
import os
import sys
from torrentool.api import Torrent

argc = len(sys.argv)
if argc == 1:
    exit()

for tor in sys.argv[1:]:
    if not tor.endswith('.torrent') or not os.path.exists(tor):
        continue
    torinfo = Torrent.from_file(tor)
    print("%11s    %s" % ("", torinfo.name))
    print("%11s    %s" % ("", torinfo.total_size))
    print("%11s    %s" % ("", torinfo.info_hash))
    for it in torinfo.files:
        print("%11d    %s" % (it.length, it.name))
Exemplo n.º 26
0
def getMagnetLink(filePath):
    try:
        torrent = Torrent.from_file(filePath)
        return torrent.magnet_link
    except FileNotFoundError:
        return None
Exemplo n.º 27
0
def torrentSize(name):
    try:
        T = Torrent.from_file(name)
        return round(T.total_size / 1024 / 1024 / 1024, 2)
    except BencodeDecodingError:
        return 0
Exemplo n.º 28
0
from bs4 import BeautifulSoup, SoupStrainer
from lxml.html import fromstring
from time import sleep
from threading import Thread
from pymorphy2 import MorphAnalyzer
from PIL import Image
from torrentool.api import Torrent
from torrentool.exceptions import BencodeDecodingError
from os import remove, system
#from libtorrent import session, torrent_info
from sqlite3 import connect
import webbrowser as wb


fixWord = lambda word, num: MorphAnalyzer().parse(word)[0].make_agree_with_number(num).word
torrentSize = lambda name: round(Torrent.from_file(name).total_size / 1024 / 1024 / 1024, 2)
URL = 'http://pickfilm.ru/search/{}/1.html'
DONATE = 'https://money.yandex.ru/to/410017272059424'
TORRENT = 'src/.torrent'
IMG = 'src/img.jpg'
ERROR = 'lib/error.jpg'
BASE = 'src/.db'
KINO = 'kino/'
ICON = 'lib/icon.ico'


def torrentSize(name):
    try:
        T = Torrent.from_file(name)
        return round(T.total_size / 1024 / 1024 / 1024, 2)
    except BencodeDecodingError: