Esempio n. 1
0
    def __run__(self):
        self.dlm.config(max_task=self.max_task)

        self.generate_name()
        path = os.path.join(self.filepath, self._title)
        for i, j in enumerate(self.video_filenames):
            filepath = os.path.join(self.filepath, self._title, j)
            if os.path.exists(filepath +
                              '.nbdler') or not os.path.exists(filepath):
                kwargs = {
                    'filename':
                    j,
                    'filepath':
                    path,
                    'max_conn':
                    self.max_conn,
                    'urls': [*list(self.video_urls[i])]
                    if isinstance(self.video_urls[i], list) or isinstance(
                        self.video_urls[i], tuple) else [self.video_urls[i]],
                    'range_formats': [self._range_format],
                    'headers': [self._headers]
                }
                dl = nbdler.open(**kwargs)

                self.dlm.addHandler(dl, name=i)
            else:
                gui.frame_main.updateBlock(i, gui.COLOR_OK)
                self._inc_progress += os.path.getsize(filepath)

        for i, j in enumerate(self.audio_filenames):
            filepath = os.path.join(self.filepath, self._title, j)
            if os.path.exists(filepath +
                              '.nbdler') or not os.path.exists(filepath):
                kwargs = {
                    'filename':
                    j,
                    'filepath':
                    path,
                    'max_conn':
                    self.max_conn,
                    'urls': [*list(self.audio_urls[i])]
                    if isinstance(self.audio_urls[i], list) or isinstance(
                        self.audio_urls[i], tuple) else [self.audio_urls[i]],
                    'range_formats': [self._range_format],
                    'headers': [self._headers]
                }
                dl = nbdler.open(**kwargs)

                self.dlm.addHandler(dl, name=i)
            else:
                gui.frame_main.updateBlock(
                    len(self.video_filenames) + i, gui.COLOR_OK)
                self._inc_progress += os.path.getsize(filepath)

        self.dlm.run()
Esempio n. 2
0
    def checkFfmpeg():
        dlm = nbdler.Manager()
        if (not os.path.exists('ffmpeg.exe') or os.path.exists('ffmpeg.exe.nbdler')) and not os.path.exists(cv.FFMPEG_PATH):
            dlg = wx.MessageDialog(None, u'该程序需要ffmpeg.exe才能完成工作,是否要下载?', u'提示', wx.YES_NO | wx.ICON_INFORMATION)
            if dlg.ShowModal() != wx.ID_YES:
                return False

            dl = nbdler.open(urls=[TOOL_REQ_URL['ffmpeg']],
                             max_conn=16, filename='ffmpeg.zip')
            dlm.addHandler(dl)
            dlg = gui.DialogGetTool(gui.frame_downloader, u'正在下载 Ffmpeg 3.2.zip', dl.getFileSize(), dlm)

            dlg.Bind(wx.EVT_TIMER, ToolReq._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            if not dlm.isEnd():
                dlm.shutdown()
                dlg.Destroy()
                return False
            ToolReq.unzip_ffmpeg('ffmpeg.zip')
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True
Esempio n. 3
0
    def checkNode():
        dlm = nbdler.Manager()
        if not os.path.exists('node.exe') or os.path.exists('node.exe.nbdler'):
            dlg = wx.MessageDialog(None, u'该程序需要Nodejs.exe才能完成工作,是否要下载?',
                                   u'提示', wx.YES_NO | wx.ICON_INFORMATION)
            if dlg.ShowModal() != wx.ID_YES:
                return False
            dl = nbdler.open(urls=[TOOL_REQ_URL['node']],
                             max_conn=16,
                             filename='node.exe')
            dlm.addHandler(dl)
            dlg = gui.DialogGetTool(gui.frame_downloader,
                                    u'正在下载 Nodejs v10.15.3', dl.getFileSize(),
                                    dlm)

            dlg.Bind(wx.EVT_TIMER, GetTool._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            dlm.shutdown()
            dlg.Destroy()
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True
Esempio n. 4
0
    def checkFfmpeg():
        dlm = nbdler.Manager()
        if (not os.path.exists('ffmpeg.exe')
                or os.path.exists('ffmpeg.exe.nbdler')) and not os.path.exists(
                    cv.FFMPEG_PATH):
            dl = nbdler.open(urls=[TOOL_REQ_URL['ffmpeg']],
                             max_conn=16,
                             filename='ffmpeg.zip')
            dlm.addHandler(dl)
            dlg = gui.DialogToolReq(gui.frame_main, u'正在下载 Ffmpeg 3.2.zip',
                                    dl.getFileSize(), dlm)

            dlg.Bind(wx.EVT_TIMER, ToolReq._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            if not dlm.isEnd():
                dlm.shutdown()
                return False
            ToolReq.unzip_ffmpeg('ffmpeg.zip')
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True
Esempio n. 5
0
    def add_handler(self, dlm, urls, path, name, dlm_name=None):
        group_done_flag = True
        filepath = os.path.join(path, name)
        if os.path.exists(filepath + '.nbdler') and os.path.exists(filepath):

            group_done_flag = False
            dl = nbdler.open(filepath, wait_for_run=self.wait_for_run)
            kwargs = {
                'urls': [*list(urls)] if isinstance(urls, list)
                or isinstance(urls, tuple) else [urls],
                'range_formats': [self._range_format],
                'headers': [self._headers],
            }
            dl.batchAdd(wait_for_run=self.wait_for_run, **kwargs)
            # dlm.addHandler(dl, name=index)
            dlm.addHandler(dl)

        elif not os.path.exists(filepath):
            group_done_flag = False
            # for mul_url in self.video_urls:

            kwargs = {
                'filename':
                name,
                'filepath':
                path,
                'max_conn':
                self.max_conn,
                'urls': [*list(urls)] if isinstance(urls, list)
                or isinstance(urls, tuple) else [urls],
                'range_formats': [self._range_format],
                'headers': [self._headers],
                'buffer_size':
                cv.BUFFER_SIZE * 1024 * 1024,
                'block_size':
                cv.BLOCK_SIZE * 1024
            }
            dl = nbdler.open(wait_for_run=self.wait_for_run, **kwargs)
            # dlm.addHandler(dl, name=index)
            if dlm_name is not None:
                dlm.addHandler(dl, name=dlm_name)
            else:
                dlm.addHandler(dl)
        else:
            self._inc_progress += os.path.getsize(filepath)

        return group_done_flag
Esempio n. 6
0
def build_dl(videoname, names_list, sel_msg):
    dlm = nbdler.Manager()
    for i, j in enumerate(names_list):
        _url, _ = iqiyi.activate_path(sel_msg['fs'][i]['l'])
        filepath = os.path.join(SAVE_PATH, videoname)

        if os.path.exists(os.path.join(filepath, j)) is True:
            if os.path.exists(os.path.join(filepath, j + '.nbdler')):
                dl = nbdler.open(fp=os.path.join(filepath, j))
                dlm.addHandler(dl)
            continue

        dl = nbdler.open(filename=j,
                         filepath=filepath,
                         max_conn=5,
                         urls=[_url])
        dlm.addHandler(dl)

    return dlm
Esempio n. 7
0
        def do(parser_info):
            avl = list(parser_info.keys())
            dlg = wx.MultiChoiceDialog(gui.frame_parse, u'以下核心可以更新', u'更新核心',
                                       avl)
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                return False
            sel = dlg.GetSelections()
            for i in sel:

                # for i, j in parser_info.items():
                dlm = nbdler.Manager()
                dl = nbdler.open(urls=[urljoin(cv.REPO, avl[i])],
                                 max_conn=3,
                                 filename=avl[i] + '.gzip',
                                 block_size=1,
                                 filepath=cv.PARSER_PATH)
                dlm.addHandler(dl)
                dlg = gui.DialogGetTool(gui.frame_parse,
                                        u'正在下载 %s.gzip' % avl[i],
                                        dl.getFileSize(), dlm)

                dlg.Bind(wx.EVT_TIMER, GetTool._process, dlg.timer)
                dlg.timer.Start(50, oneShot=False)
                dlm.run()
                msg = dlg.ShowModal()
                if msg != wx.ID_OK:
                    return False
                else:
                    try:
                        with open(os.path.join(cv.PARSER_PATH, avl[i]),
                                  'w') as f:
                            f.write(
                                gzip.open(
                                    os.path.join(
                                        cv.PARSER_PATH, avl[i] +
                                        '.gzip')).read().decode('utf-8'))
                        os.remove(
                            os.path.join(cv.PARSER_PATH, avl[i] + '.gzip'))
                    except:
                        dlg = wx.MessageDialog(gui.frame_parse,
                                               traceback.format_exc(), avl[i],
                                               wx.OK | wx.ICON_ERROR)
                        dlg.ShowModal()
                        dlg.Destroy()

            dlg.Destroy()
            dlg = wx.MessageDialog(gui.frame_parse, '核心更新完成!', '提示',
                                   wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()

            LoadParserCore.handle()
Esempio n. 8
0
def build_dl(names_list, sel_msg):
    global dlm, video_title, all_filename
    for i, j in enumerate(all_filename):
        _url, _ = iqiyi.activatePath(sel_msg['fs'][i]['l'])
        filepath = os.path.join(target_path, video_title)
        if os.path.exists(os.path.join(
                filepath, j +
                u'.nbdler')) or not os.path.exists(os.path.join(filepath, j)):
            dl = nbdler.open(filename=j,
                             filepath=filepath,
                             max_conn=5,
                             urls=[_url],
                             wait=True)
            dlm.addHandler(dl, name=i)
        else:
            gui.frame_main.updateBlock(i, gui.COLOR_OK)

    return dlm
Esempio n. 9
0
    def checkNode():
        dlm = nbdler.Manager()
        if not os.path.exists('node.exe') or os.path.exists('node.exe.nbdler'):
            dl = nbdler.open(urls=[TOOL_REQ_URL['node']],
                             max_conn=16,
                             filename='node.exe')
            dlm.addHandler(dl)
            dlg = gui.DialogToolReq(gui.frame_main, u'正在下载 Nodejs v0.12.18',
                                    dl.getFileSize(), dlm)

            dlg.Bind(wx.EVT_TIMER, ToolReq._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            dlm.shutdown()
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True
Esempio n. 10
0
def build_dl():
    global all_filename, sel_res, inc_filesize

    tmp_dlm = nbdler.Manager()
    all_urls = sel_res.getVideosFullUrl()
    video_title = sel_res.getVideoTitle()
    for i, j in enumerate(all_filename):
        filepath = os.path.join(target_path, video_title)
        if os.path.exists(os.path.join(
                filepath, j +
                u'.nbdler')) or not os.path.exists(os.path.join(filepath, j)):
            dl = nbdler.open(filename=j,
                             filepath=filepath,
                             max_conn=3,
                             urls=[all_urls[i]])
            if sel_res.getM3U8():
                dl.setRangeFormat('&start=%d&end=%d')
            tmp_dlm.addHandler(dl, name=i)
        else:
            gui.frame_main.updateBlock(i, gui.COLOR_OK)
            inc_filesize += os.path.getsize(os.path.join(filepath, j))

    return tmp_dlm