예제 #1
0
    def __init__(self):
        self.dlm = nbdler.Manager()

        self.filepath = ''

        self.max_task = 5
        self.max_conn = 3

        self.video_urls = []
        self.audio_urls = []

        self._res = None
        self._title = None
        self._filenum = 0
        self._ext = ''
        self.video_filenames = []
        self.audio_filenames = []
        self._inc_progress = 0

        self._range_format = 'Range: bytes=%d-%d'
        self._headers = {
            'Connection': 'keep-alive',
            'User-Agent':
            'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36',
            'Accept': '*/*',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'zh-CN,zh;q=0.9'
        }

        self._thr = None
예제 #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
예제 #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
예제 #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
예제 #5
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()
예제 #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
예제 #7
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
예제 #8
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
예제 #9
0
    def __run__(self):
        self.dlm.config(max_task=self.max_task)

        self.generate_name()
        if len(self.video_filenames) + len(self.audio_filenames) > 100:
            self.wait_for_run = True
        path = os.path.join(self.filepath, self._title)

        ######################## video
        file_counter = 0
        for i, j in enumerate(self.video_urls):

            if isinstance(j, BasicUrlGroup):
                group_done_flag = True
                group_dlm = nbdler.Manager()
                group_dlm.config(max_task=cv.MAX_TASK)
                for index, cur_urls in enumerate(j):

                    if not self.add_handler(
                            group_dlm, cur_urls, path,
                            self.video_filenames[file_counter]):
                        group_done_flag = False
                    file_counter += 1

                self.dlm.addHandler(group_dlm, name=i)
            elif isinstance(j, list) or isinstance(j, tuple):
                group_done_flag = self.add_handler(
                    self.dlm, list(j), path,
                    self.video_filenames[file_counter], i)
                file_counter += 1
            elif isinstance(j, str):
                group_done_flag = self.add_handler(
                    self.dlm, [j], path, self.video_filenames[file_counter], i)
                file_counter += 1
            else:
                raise TypeError(
                    'downloader got an unsupported type %s , should be list or tuple'
                    % str(type(j)))

            if group_done_flag:
                gui.frame_downloader.updateBlock(i, gui.COLOR_OK)

        ######################## audio

        file_counter = 0
        for i, j in enumerate(self.audio_urls):

            if isinstance(j, BasicUrlGroup):
                group_done_flag = True
                group_dlm = nbdler.Manager()
                group_dlm.config(max_task=cv.MAX_TASK)
                for index, cur_urls in enumerate(j):

                    if not self.add_handler(
                            group_dlm, cur_urls, path,
                            self.audio_filenames[file_counter]):
                        group_done_flag = False
                    file_counter += 1

                if group_done_flag:
                    gui.frame_downloader.updateBlock(i, gui.COLOR_OK)

                self.dlm.addHandler(group_dlm, name=i)
            elif isinstance(j, list) or isinstance(j, tuple):

                self.add_handler(self.dlm, list(j), path,
                                 self.audio_filenames[file_counter], i)
                file_counter += 1
            elif isinstance(j, str):
                self.add_handler(self.dlm, [j], path,
                                 self.audio_filenames[file_counter], i)
                file_counter += 1
            else:
                raise TypeError(
                    'downloader got an unsupported type %s , should be list or tuple'
                    % str(type(j)))

        self.dlm.run()
예제 #10
0
import gui
import iqiyi_parse as iqiyi
import json, os, time
import threading
from merger import Merger
import wx
import nbdler
import GUIEventBinder
import socket
socket.setdefaulttimeout(5)

dlm = nbdler.Manager()
total_filesize = 0
max_task = 5
target_path = ''
video_title = ''
resolution = ''
sel_bid = None
all_filename = []


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,