Example #1
0
def build_cache(identity):
        enter(identity)
        completed = xmlrpc('d.multicall2', ('', 'complete', 'd.timestamp.finished=', 'd.custom1=', 't.multicall=,t.url=,t.scrape_complete=', 'd.ratio=', 'd.size_bytes=', 'd.name=', 'd.hash=', 'd.directory='))
        completed.sort()
        [list.append(list[7].rsplit('/', 1)[0]) if list[5] in list[7] else list.append(list[7]) for list in completed]
        leeching = xmlrpc('d.multicall2', ('', 'leeching', 'd.left_bytes=', 'd.custom1=', 't.multicall=,t.url=,t.scrape_complete=', 'd.ratio=','d.size_bytes=', 'd.name=', 'd.hash=', 'd.directory='))
        [list.append(list[7].rsplit('/', 1)[0]) if list[5] in list[7] else list.append(list[7]) for list in leeching]
        if xmlrpc('system.file.allocate',('',)):
                for list in leeching:
                        if list[5] in list[7]:
                                list[0]=list[4]-folder_size(list[7])
                        else:
                                list[0]=list[4]-os.stat(list[7]+list[5]).st_size
        cache = open(cache_copy, mode='w+')
        cache.write('completed = ' + pprint.pformat(completed))
        cache.write('\n\nleeching = ' + pprint.pformat(leeching))
        shutil.move(cache_copy, torrent_cache)
        leave(identity)

        if not os.path.isfile(mp_cache):
                mount_points = {}
        else:
                from mountpoints import mount_points
                mp_updated = False
        for list in completed + leeching:
                parent_directory = list[8]
                if parent_directory not in mount_points:
                        mp_updated = True
                        mount_point = [path for path in [parent_directory.rsplit('/', num)[0] for num in range(parent_directory.count('/'))] if os.path.ismount(path)]
                        mount_point = mount_point[0] if mount_point else '/'
                        mount_points[parent_directory] = mount_point
        if mp_updated:
                open(mp_cache, mode='w+').write('mount_points = ' + pprint.pformat(mount_points))
Example #2
0
def imdb_search():

    try:
        from threading import Thread
        from guessit import guessit
        from imdbpie import Imdb

        def imdb_ratings():
            ratings.update(imdb.get_title_ratings(movie_imdb))

        def movie_country():
            country.extend(imdb.get_title_versions(movie_imdb)['origins'])

        imdb = Imdb()
        torrent_info = guessit(torrent_name)
        movie_title = torrent_info['title'] + ' ' + str(torrent_info['year'])
        movie_imdb = imdb.search_for_title(movie_title)[0]['imdb_id']

        ratings = {}
        country = []
        t1 = Thread(target=movie_country)
        t2 = Thread(target=imdb_ratings)
        t1.start()
        t2.start()
        t1.join()
        t2.join()
    except:
        return

    rating = ratings['rating']
    votes = ratings['ratingCount']

    if rating < minimum_rating or votes < minimum_votes:
        xmlrpc('d.erase', (torrent_hash, ))
        sys.exit()

    if skip_foreign and 'US' not in country:
        xmlrpc('d.erase', (torrent_hash, ))
        sys.exit()
Example #3
0
                continue

            del completed[0]
        else:
            parent_directory, t_hash, t_path, t_size_b, t_size_g = fallback_torrents.pop(
                0)

        if mount_points[parent_directory] != mount_point:
            continue
        elif quota_path and quota_path not in parent_directory and mp_freed_space >= mp_required_space:
            continue
        elif quota_path and quota_path in parent_directory and quota_freed_space >= quota_required_space:
            continue

        try:
            xmlrpc('d.open', (t_hash, ))
        except:
            continue

        if not deleted:
            open(subtractions, mode='w+').write('0')

        removable.append((t_size_g, t_hash, t_path))
        deleted += t_size_b
        mp_freed_space += t_size_g
        if quota_path and quota_path in parent_directory:
            quota_freed_space += t_size_g
            quota_deleted += t_size_b

    if mp_freed_space >= mp_required_space and (
            not quota_path or quota_freed_space >= quota_required_space):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, os, cacher, time
from torrents import completed
from remotecaller import xmlrpc

queue = sys.argv[1]
torrent_hash = sys.argv[2]
torrent_path = sys.argv[3]
subtractions = sys.argv[4]

files = xmlrpc('f.multicall',
               (torrent_hash, '', 'f.size_bytes=', 'f.frozen_path='))
t_hash = (torrent_hash, )
xmlrpc('d.tracker_announce', t_hash)
xmlrpc('d.erase', t_hash)

with open(queue, 'a+') as txt:
    txt.write(torrent_hash + '\n')

time.sleep(0.001)

while True:

    try:
        with open(queue, 'r') as txt:
            queued = txt.read().strip().splitlines()
    except:
        with open(queue, 'a+') as txt:
            txt.write(torrent_hash + '\n')
Example #5
0
            for result in displayed:

                if not PY2:
                    textfile.write(result + '\n')
                else:
                    textfile.write(result.encode('utf8') + '\n')

        print('\n===== Test for Torrent Download in %s =====\n\n%s' %
              (tested_path, now))
        print(
            'Executed in %s seconds\n%s Torrent(s) Deleted Totaling %.2f GB' %
            (time, count, mp_freed_space))
        print(
            '%.2f GB Free Space Before Torrent Download (minimum space %.2f GB)\n%.2f GB Free Space After %.2f GB Torrent Download\n'
            % (available_space, min_sp[tested_path], calc, torrent_size))
        if calc < 0:
            print('Cannot free enough space!\n')
        for result in displayed:
            print(result)
        completed = completed_copy[:]

except Exception as e:
    print(e)

try:
    xmlrpc('d.multicall2', ('', 'leeching', 'd.down.total='))
except:
    print(
        'SCGI address not configured properly. Please adjust it in your config.py file before continuing.'
    )
    sys.exit()