def __init__(self,
                 project_dir,
                 data_to_download,
                 common_utils_dir='automatic'):
        os.chdir(project_dir)
        print('>>>>>Confirm Project Directory: ' + project_dir)

        print('common_utils_dir: ' + common_utils_dir)
        print(type(common_utils_dir))

        if common_utils_dir == 'automatic':
            common_utils_dir = project_dir + '/COMMON_UTILS'
        print('new common_utils_dir: ' + common_utils_dir)
        print(type(common_utils_dir))
        self.download_common_utils(common_utils_dir)
        from pyaria2 import PyAria2  ###############################################################???

        downloader = PyAria2()
        #def add_files_to_aria(self, downloader, project_dir, data_to_download, common_utils_dir):

        self.__add_files_to_aria(downloader, project_dir, data_to_download,
                                 common_utils_dir)
        self.printDownloadStatus(downloader)
        #
        #        print('\n Unzipping')
        #        self.unzip_all(project_dir, data_to_download)

        print('\n ############## Downloading Complete ##############')
Esempio n. 2
0
    def initiate(self,
                 project_dir,
                 data_to_download,
                 common_utils_dir='default',
                 recreate_dir=True):
        if not os.path.isdir(project_dir):
            os.makedirs(project_dir)
        elif recreate_dir == True:
            shutil.rmtree(project_dir)
            os.makedirs(project_dir)

        os.chdir(project_dir)
        print('>>>>>Confirm Project Directory: ' + project_dir)
        sys.path.insert(0, project_dir)

        if common_utils_dir == 'default':
            common_utils_dir = project_dir + '/COMMON_UTILS'

        self.__download_common_utils(common_utils_dir)
        from pyaria2 import PyAria2  ###############################################################???

        downloader = PyAria2()
        time.sleep(1)

        self.__add_files_to_aria(downloader, project_dir, data_to_download,
                                 common_utils_dir)
        self.__printDownloadStatus(downloader)

        print('\n>>>Unzipping')
        self.__unzip_all(project_dir, data_to_download)

        #self.showDirectory(project_dir)

        self.all_gids = []
        del downloader
    def initiate(self,
                 project_dir,
                 data_to_download,
                 common_utils_dir='default'):
        if not os.path.isdir(project_dir):
            os.mkdir(project_dir)

        os.chdir(project_dir)
        print('>>>>>Confirm Project Directory: ' + project_dir)

        if common_utils_dir == 'default':
            common_utils_dir = project_dir + '/COMMON_UTILS'

        self.__download_common_utils(common_utils_dir)
        from pyaria2 import PyAria2  ###############################################################???

        downloader = PyAria2()
        time.sleep(2)

        self.__add_files_to_aria(downloader, project_dir, data_to_download,
                                 common_utils_dir)
        self.__printDownloadStatus(downloader)

        print('\n>>>Unzipping')
        self.__unzip_all(project_dir, data_to_download)

        self.showDirectory(project_dir)

        self.self_all_gids = []
Esempio n. 4
0
def get_daemon(secret=None):
    global __aria2daemon__

    if __aria2daemon__ is None:
        aria_settings = AriaServerSettings()
        aria_settings.continue_flag = True

        if secret is not None:
            aria_settings.rpc_secret = secret

        __aria2daemon__ = PyAria2(aria_settings)
    return __aria2daemon__
Esempio n. 5
0
 def __init__(self,
              host="localhost",
              port=6800,
              useRPCSecret=False,
              fixedSecret=None,
              globalOptions=None):
     self.host = host
     self.port = port
     #self.useRPCSecret = useRPCSecret
     #print("[AriaCommunicator.__init] use secret: {0}".format(self.useRPCSecret))
     secret = fixedSecret or self.generateSecret()
     #self.rpcSecret = "token:{0}".format(secret)
     rpc_conf = {"useSecret": useRPCSecret, "secret": secret}
     self.ariaObj = PyAria2(self.host, self.port, rpcSecret=rpc_conf)
     if globalOptions:
         self.setGlobalOptions(globalOptions)
Esempio n. 6
0
    def visit(self):
        print("去抓取")
        url = 'http://www.xicidaili.com/nn'  # 西刺代理扒拉下来的
        rq = urllib.request.Request(url, headers=self.headers)
        response = urllib.request.urlopen(rq)
        self.parse(response.read())

    def parse(self, html):
        list_ip = []
        soup = BeautifulSoup(html, "html.parser")
        datas = soup.find_all('tr', class_='odd')
        for data in datas:
            tds = data.findAll('td')
            ProxyId.ips.append(tds[1].text + ':' + tds[2].text)


if __name__ == '__main__':
    pya = PyAria2()
    with open('output.html', encoding='utf-8') as f:
        soup = BeautifulSoup(f.read(), 'html.parser')
        dates = soup.find_all('td')
        for data in dates:
            if 'mp4' in data.text:
                urls = []
                urls.append(data.text)
                pya.addUri(urls)
    # print(os.environ['PATH'])
    # print(urls)
    # url = ['http://d.b612kj.com/assets/7b5954466442c9a1d16e8a37003a28aa.mp4']
    # pya.addUri(url)
Esempio n. 7
0
import uuid
from mutagen.mp4 import MP4, MP4Cover, AtomDataType
from collections import OrderedDict

from pyaria2 import PyAria2


def generate_filename(value):
    return "".join(i for i in value if i not in r'\/:*?"<>|')


def generate_token():
    return uuid.uuid1().__str__().replace('-', '') + "@@NOLOGIN"


aria2 = PyAria2('localhost', 6800)
pp = pprint.PrettyPrinter(indent=4)

token = generate_token()

HEADERS = OrderedDict([
    ("Content-Type", "application/json; charset=UTF-8"),
    ("Host", "best.rec" + "ochoku.jp"),
    ("Origin", "https://best.rec" + "ochoku.jp"),
    ("Referer", "https://best.reco" + "choku.jp/?"),
    ("User-Agent",
     "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99"
     " Safari/537.36"),
    ("X-Requested-With", "XMLHttpRequest")]
)
Esempio n. 8
0
def getAria2cClientInstance():
    return PyAria2(host='localhost', port=6800)  # configure here
Esempio n. 9
0
app = Flask(__name__)

APP_ROOT = os.path.dirname(os.path.abspath(__file__))
DOWNLOAD_FOLDER = os.path.join(APP_ROOT, 'static/downloads')

app.config['MONGO_DBNAME'] = 'torrentmirror'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/torrentmirror'
app.config['DOWNLOAD_FOLDER'] = DOWNLOAD_FOLDER
app.secret_key = 'mysecret'

app.config.update(CELERY_BROKER_URL='redis://localhost:6379',
                  CELERY_RESULT_BACKEND='redis://localhost:6379')

mongo = PyMongo(app)
client = PyAria2('localhost', 6000)


def make_celery(app):
    celery = Celery(app.import_name,
                    backend=app.config['CELERY_RESULT_BACKEND'],
                    broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task

    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)