Пример #1
0
class YouGet():
    def __init__(self, **kwargs):
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()
        self.common = Common()

    def save_path(self):
        parallel = os.path.abspath(os.path.dirname(BASE_DIR))
        flv_path = self.common.mkdir(os.path.join(parallel, 'you_get'))
        return flv_path

    def download(self, url):
        sys.argv = ['you-get', '-o', self.path, url]
        you_get.main()

        # 下载完成,删除xml文件
        for file in os.listdir(self.path):
            if file[-3:] == 'xml':
                self.common.rmfile(os.path.join(self.path, file))
Пример #2
0
class Thunder():
    def __init__(self, **kwargs):
        self.common = Common()
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()

        from win32com.client import Dispatch
        self.thunder = Dispatch('ThunderAgent.Agent64.1')

    def save_path(self):
        parallel = os.path.abspath(os.path.dirname(BASE_DIR))
        flv_path = self.common.mkdir(os.path.join(parallel, 'you_get'))
        return flv_path

    def download1(self, urls):
        for i, url in enumerate(urls):
            self.thunder.AddTask(url, "第{0}集.rmvb".format(i + 1), self.path)
            self.thunder.CommitTasks()

    def download(self, url, name):
        self.thunder.AddTask(url, "第{0}集.rmvb".format(name))
        self.thunder.CommitTasks()
        time.sleep(60)