Beispiel #1
0
def gen_layer():

    if os.path.isfile(os.getcwd() + '\\config.cfg'):
        config_r = open(os.getcwd() + '\\config.cfg', 'r')
        lines = config_r.readlines()
        param_dic = {}
        for line in lines:
            line = line.split('\n')
            para = line[0].split('=')[0]
            val = line[0].split('=')[1]
            param_dic[para] = val
        # if 'fdir' in param_dic:
        try:
            sg_input_dir = sg.Input(param_dic['fdir'].decode('gbk'))
            sg_input_excel = sg.Input(param_dic['f_excel'].decode('gbk'))
        except:
            sg_input_excel = sg.Input('')
            sg_input_dir = sg.Input('')
    else:
        sg_input_excel = sg.Input('')
        sg_input_dir = sg.Input('')
    layout1 = [[sg.Text('输入图例Excel'.decode('gbk'))],
               [sg_input_excel, sg.FileBrowse()],
               [sg.Text('定义目录文件'.decode('gbk'))],
               [sg_input_dir, sg.FolderBrowse()],
               [sg.Text('不带*的用户名文件(如果不需要此功能请留空)'.decode('gbk'))],
               [sg.Input(''), sg.FileBrowse()],
               [sg.OK()] ]
    window1 = sg.Window('生成图层'.decode('gbk'),font=("Helvetica", 20)).Layout(layout1)

    while 1:

        event1, values1 = window1.Read()
        if event1 is None:
            break
        # print(values1)
        f_excel = values1[0].encode('gbk')
        fdir = values1[1].encode('gbk')
        additional_excel = values1[2].encode('gbk')

        # print(additional_excel)
        # exit()
        # print(fdir)
        # print(f_excel)
        config = codecs.open(os.getcwd() + '\\' + 'config.cfg', 'w')
        config.write('fdir=' + fdir + '\n')
        config.write('f_excel=' + f_excel + '\n')
        config.close()

        p = multiprocessing.Process(target=kernel_gen_layer, args=(fdir, f_excel, additional_excel))
        p.start()
        window1.Close()

        break
def merge():
    if os.path.isfile(os.getcwd() + '\\merge_config.cfg'):
        config_r = open(os.getcwd() + '\\merge_config.cfg', 'r')
        lines = config_r.readlines()
        param_dic = {}
        for line in lines:
            line = line.split('\n')
            para = line[0].split('=')[0]
            val = line[0].split('=')[1]
            param_dic[para] = val
        # if 'fdir' in param_dic:
        try:
            sg_input_dir = sg.Input(param_dic['fdir'].decode('gbk'))
            sg_input_out_dir = sg.Input(param_dic['out_dir'].decode('gbk'))
        except:
            sg_input_out_dir = sg.Input('')
            sg_input_dir = sg.Input('')
    else:
        sg_input_out_dir = sg.Input('')
        sg_input_dir = sg.Input('')
    layout1 = [[sg.Text('输入需要合并的文件夹'.decode('gbk'))],
               [sg_input_dir, sg.FolderBrowse()],
               [sg.Text('输出目录'.decode('gbk'))],
               [sg_input_out_dir, sg.FolderBrowse()],
               [sg.OK()] ]
    window1 = sg.Window('合并图层'.decode('gbk'),font=("Helvetica", 20)).Layout(layout1)

    while 1:

        event1, values1 = window1.Read()
        if event1 is None:
            break
        # print(values1)
        indir = values1[0]
        outdir = values1[1]
        print(indir)
        print(outdir)
        # exit()
        config = codecs.open(os.getcwd() + '\\' + 'merge_config.cfg', 'w')
        config.write('fdir=' + indir.encode('gbk') + '\n')
        config.write('out_dir=' + outdir.encode('gbk') + '\n')
        config.close()
        indir = indir.encode('gbk')
        outdir = outdir.encode('gbk')
        merge_shp.Merge().merge(indir,outdir)
        # yongcheng.Merge().merge_point_annotation_shp(indir,outdir)
        # yongcheng.Merge().merge_daoxian(indir,outdir)
        # yongcheng.main(fdir+'/',f_excel)
        sg.Popup('图层生成完毕!\n按OK结束'.decode('gbk'))
        window1.Close()
        break
def main():
    # layout1 = [
    #             [sg.Radio('1.dwg转shp'.decode('gbk'), "RADIO1")],
    #           [sg.Radio('2.生成layer'.decode('gbk'), "RADIO1")],
    #           [sg.Radio('3.出图'.decode('gbk'), "RADIO1")],
    #            [sg.Radio('4.合并图层'.decode('gbk'), "RADIO1")],
    #             [sg.Radio('5.更新代码'.decode('gbk'), "RADIO1")],
    #            [sg.OK()]
    #            ]

    layout1 = [[sg.InputCombo(('1.dwg转shp'.decode('gbk'), '2.生成layer'.decode('gbk'), '3.出图'.decode('gbk'), '4.合并图层'.decode('gbk'),'0.更新代码'.decode('gbk')), size=(20, 1))],
               [sg.OK()]]

    window1 = sg.Window('自动制图'.decode('gbk'),layout1,font=("Helvetica", 20))
    while 1:
        event1, values1 = window1.Read()
        # print(values1)
        if event1 is None:
            break
        if values1[0] == '5.更新代码'.decode('gbk'):
            py_scrpit = 'd:\\zhongyaxianlutu\\cui_project_191116\\cui_project\\py27\\update_script.py'
            update_script(py_scrpit)
        elif values1[0] == '1.dwg转shp'.decode('gbk'):
            dwg_to_shp()
        elif values1[0] == '2.生成layer'.decode('gbk'):
            gen_layer()
        elif values1[0] == '3.出图'.decode('gbk'):
            mapping()
        elif values1[0] == '4.合并图层'.decode('gbk'):
            merge()

    # while 1:
    #     print('input number:')
    #     print('0.更新代码\n1.dwg转shp\n2.生成layer\n3.出图\n4.合并图层')
    #     input_num = raw_input('input:')
    #     if input_num == '0':
    #         py_scrpit = 'd:\\zhongyaxianlutu\\cui_project_191116\\cui_project\\py27\\update_script.py'
    #         update_script(py_scrpit)
    #     elif input_num == '1':
    #         dwg_to_shp()
    #         pass
    #     elif input_num == '2':
    #         gen_layer()
    #         pass
    #     elif input_num == '3':
    #         mapping()
    #         pass
    #     elif input_num == '4':
    #         merge()
            pass
Beispiel #4
0
def main():
    # layout1 = [[sg.Text('1.dwg转shp'.decode('gbk'))],
    #            [sg.Text('2.生成layer'.decode('gbk'))],
    #            [sg.Text('3.出图'.decode('gbk'))],
    #            [sg.OK()]]
    layout1 = [
              [sg.Radio('1.生成layer'.decode('gbk'), "RADIO1")],
              [sg.Radio('2.出图'.decode('gbk'), "RADIO1")],
                             [sg.OK()]
               ]

    window1 = sg.Window('自动制图'.decode('gbk'),layout1,font=("Helvetica", 20))
    while 1:
        event1, values1 = window1.Read()
        # print(values1)
        if event1 is None:
            break
        if values1[0]:
            gen_layer()
        if values1[1]:
            mapping()
def dwg_to_shp():
    if os.path.isfile(os.getcwd() + '/config_dwg_to_shp.cfg'):
        config_r = open(os.getcwd() + '/config_dwg_to_shp.cfg', 'r')
        lines = config_r.readlines()
        param_dic = {}
        for line in lines:
            line = line.split('\n')
            para = line[0].split('=')[0]
            val = line[0].split('=')[1]
            param_dic[para] = val
        # if 'fdir' in param_dic:
        try:
            sg_input_dir = sg.Input(param_dic['input_dir'].decode('gbk'))
            sg_arcgis_python = sg.Input(param_dic['arcgis_python'].decode('gbk'))
            sg_input_python_script = sg.Input(param_dic['input_python_scrip'].decode('gbk'))
            sg_out_dir = sg.Input(param_dic['out_dir'].decode('gbk'))

        except:
            sg_input_dir = sg.Input('')
            sg_arcgis_python = sg.Input('')
            sg_input_python_script = sg.Input('')
            sg_out_dir = sg.Input('')
    else:
        sg_input_dir = sg.Input('')
        sg_arcgis_python = sg.Input('')
        sg_input_python_script = sg.Input('')
        sg_out_dir = sg.Input('')

    layout1 = [
        [sg.Text('arcgis 的 python.exe'.decode('gbk'))],
        [sg_arcgis_python, sg.FileBrowse()],

        [sg.Text('dwg转shp脚本.py'.decode('gbk'))],
        [sg_input_python_script, sg.FileBrowse()],

        [sg.Text('dwg目录'.decode('gbk'))],
        [sg_input_dir, sg.FolderBrowse()],

        [sg.Text('dwg转shp输出目录'.decode('gbk'))],
        [sg_out_dir, sg.FolderBrowse()],
        [sg.OK()]
    ]

    window1 = sg.Window('dwg转shp'.decode('gbk'),font=("Helvetica", 20)).Layout(layout1)
    while 1:

        event1, values1 = window1.Read()
        if event1 is None:
            break
        arcgis_python = values1[0]
        input_python_script = values1[1]
        input_dir = values1[2]
        out_dir = values1[3]

        config = codecs.open(os.getcwd() + '/' + 'config_dwg_to_shp.cfg', 'w')
        config.write('arcgis_python=' + arcgis_python.encode('gbk') + '\n')
        config.write('input_python_scrip=' + input_python_script.encode('gbk') + '\n')
        config.write('input_dir=' + input_dir.encode('gbk') + '\n')
        config.write('out_dir=' + out_dir.encode('gbk') + '\n')

        config.close()
        input_dir = input_dir.replace('/','\\')
        out_dir = out_dir.replace('/','\\')

        params = [arcgis_python,input_python_script,input_dir,out_dir]
        p = multiprocessing.Process(target=kernel_dwg_to_shp, args=[params])
        p.start()
        window1.Close()
        break
def mapping():
    if os.path.isfile(os.getcwd() + '/config_mapping.cfg'):
        config_r = open(os.getcwd() + '/config_mapping.cfg', 'r')
        lines = config_r.readlines()
        param_dic = {}
        for line in lines:
            line = line.split('\n')
            para = line[0].split('=')[0]
            val = line[0].split('=')[1]
            param_dic[para] = val
        # if 'fdir' in param_dic:
        try:
            sg_input_dir = sg.Input(param_dic['fdir'].decode('gbk'))
            sg_arcgis_python = sg.Input(param_dic['arcgis_python'].decode('gbk'))
            sg_input_python_script = sg.Input(param_dic['mapping_script'].decode('gbk'))
            sg_input_ditu = sg.Input(param_dic['input_ditu'].decode('gbk'))
            sg_out_pic_dir = sg.Input(param_dic['out_pic_dir'].decode('gbk'))
            sg_heng_template = sg.Input(param_dic['heng_template'].decode('gbk'))
            sg_shu_template = sg.Input(param_dic['shu_template'].decode('gbk'))
        except:
            sg_arcgis_python = sg.Input('')
            sg_input_python_script = sg.Input('')
            sg_input_ditu = sg.Input('')
            sg_input_dir = sg.Input('')
            sg_out_pic_dir = sg.Input('')
            sg_heng_template = sg.Input('')
            sg_shu_template = sg.Input('')
    else:
        sg_arcgis_python = sg.Input('')
        sg_input_dir = sg.Input('')
        sg_input_python_script = sg.Input('')
        sg_input_ditu = sg.Input('')
        sg_out_pic_dir = sg.Input('')
        sg_heng_template = sg.Input('')
        sg_shu_template = sg.Input('')
    layout1 = [
            [sg.Text('arcgis 的 python.exe'.decode('gbk'))],
            [sg_arcgis_python, sg.FileBrowse()],
            [sg.Text('制图脚本.py'.decode('gbk'))],
            [sg_input_python_script, sg.FileBrowse()],
            [sg.Text('底图'.decode('gbk'))],
            [sg_input_ditu, sg.FolderBrowse()],
            [sg.Text('横mxd模板.mxd'.decode('gbk'))],
            [sg_heng_template, sg.FileBrowse()],
            [sg.Text('竖mxd模板.mxd'.decode('gbk'))],
            [sg_shu_template, sg.FileBrowse()],

            [sg.Radio('A0'.decode('gbk'), "RADIO1"),sg.Radio('A3'.decode('gbk'), "RADIO1")],
            # [sg.Radio('A3'.decode('gbk'), "RADIO1")],

            [sg.Text('制图目录'.decode('gbk'))],
            [sg_input_dir, sg.FolderBrowse()],
            [sg.Text('图片输出目录'.decode('gbk'))],
            [sg_out_pic_dir, sg.FolderBrowse()],
            [sg.OK()]
    ]
    window1 = sg.Window('arcpy制图'.decode('gbk'),font=("Helvetica", 20)).Layout(layout1)
    while 1:

        event1, values1 = window1.Read()
        # print event1
        # print values1
        if event1 is None:
            break
        arcgis_python = values1[0]
        mapping_script = values1[1]
        mapping_input_ditu = values1[2]
        heng_template = values1[3]
        shu_template = values1[4]
        a0 = values1[5]
        a3 = values1[6]
        fdir = values1[7]
        out_pic_dir = values1[8]

        config = codecs.open(os.getcwd() + '/' + 'config_mapping.cfg', 'w')
        config.write('fdir=' + fdir.encode('gbk') + '\n')
        config.write('mapping_script=' + mapping_script.encode('gbk') + '\n')
        config.write('input_ditu=' + mapping_input_ditu.encode('gbk') + '\n')
        config.write('arcgis_python=' + arcgis_python.encode('gbk') + '\n')
        config.write('out_pic_dir=' + out_pic_dir.encode('gbk') + '\n')
        config.write('heng_template=' + heng_template.encode('gbk') + '\n')
        config.write('shu_template=' + shu_template.encode('gbk') + '\n')
        # config.write('a0=' + str(a0) + '\n')
        # config.write('a3=' + str(a3) + '\n')
        config.close()
        # print(arcgis_python+' '+mapping_script)
        fdir = fdir.replace('/','\\')
        out_pic_dir = out_pic_dir.replace('/','\\')
        size = ''
        if a0:
            size = 'a0'
        if a3:
            size = 'a3'
        params = [arcgis_python,mapping_script,fdir,out_pic_dir,mapping_input_ditu,heng_template,shu_template,size]
        p = multiprocessing.Process(target=kernel_mapping, args=[params])
        p.start()

        window1.Close()
        break
Beispiel #7
0
def main():

    valid_input = []
    for i in range(10):
        valid_input.append(str(i))
    valid_input.append(':')
    valid_input.append('.')
    # print(valid_input)
    # exit()
    text = sg.Text('input IP or domain and port', auto_size_text=1, font=Font)

    text1 = sg.Text('select IP and port', auto_size_text=1, font=Font)
    sg_input = sg.Input()

    fr = open('ipconfig.txt')
    lines = fr.readlines()
    fr.close()
    listbox = []
    for line in lines:
        line = line.split('\n')[0]
        listbox.append(line)

    sg_listbox = sg.Listbox(listbox, size=(40, 10), font=Font)
    layout1 = [[text], [sg_input], [text1], [sg_listbox],
               [sg.OK(), sg.Cancel()]]

    window1 = sg.Window('proxy').Layout(layout1)

    while 1:
        event1, values1 = window1.Read()
        if event1 == None:
            break
        break_flag = 0
        # for str_ in values1[0]:
        #     if str_ not in valid_input:
        #         sg.Popup(u'输入有误', title=u'错误', font=Font)
        #         break_flag = 1
        #         break

        if len(values1[0]) == len(values1[1]) == 0:
            sg.Popup(u'请选择', title=u'错误', font=Font)
            continue
        if break_flag == 1:
            sg_input.Update('')
            continue

        if len(values1[0]) > 0:
            # print(1)
            ip = values1[0]
        else:
            ip = values1[1][0]
            # sg_input.Update(ip)
        if ip == 0 or ip == 'clear':
            clear_proxy()
        else:
            set_proxy(ip)
        sg_input.Update('')
        # print(ip)
        # print(values1)

        # print(ip)
    pass
Beispiel #8
0
def main():

    text = sg.Text(
        '请输入视频网址(例如:http://532movie.bnu.edu.cn/movie/3981.html)\n或输入搜索关键词(例如: 周星驰 或 喜剧之王):'
        .decode('utf-8'),
        auto_size_text=1,
        font=Font)
    layout1 = [
        [text],
        [sg.Input(), sg.OK(u'搜索')],
    ]

    window1 = sg.Window('Download 532 Movies').Layout(layout1)

    # win2_active = 0
    while 1:
        event1, values1 = window1.Read()
        if not check_connection():
            sg.PopupError(u'连接错误\n请检查网络是否能连接 532movie.bnu.edu.cn',
                          title=u'错误',
                          font=Font)
            continue
        if event1 is None:
            break
        print(values1)
        key_word = values1[0]
        if len(key_word) < 2:
            sg.Popup('请多于2个关键词'.decode('utf-8'))
            continue

        if key_word.startswith('http'):
            movie_name, _ = get_vedio_url(key_word)
            movie_name = [movie_name]
            urls = [key_word]
        else:
            movie_name, urls = search(key_word)
        # key_word = key_word.encode('utf-8')
        for i in movie_name:
            print(i)
        movie_dic = {}
        listbox = []
        for i in range(len(movie_name)):
            movie_dic[movie_name[i].decode('utf-8')] = urls[i]
            listbox.append(movie_name[i].decode('utf-8'))

        if len(movie_name) > 0 and not event1 is None:
            # listbox = movie_name
            sg_listbox = sg.Listbox(listbox, size=(50, 10), font=Font)
            text1 = u'%s\n 搜索结果:共有%s条,请选择要下载的影片' % (key_word, len(movie_name))
            if os.path.isfile(os.getcwd() + '\\config.cfg'):
                config_r = open(os.getcwd() + '\\config.cfg', 'r')
                lines = config_r.readlines()
                param_dic = {}
                for line in lines:
                    line = line.split('\n')
                    para = line[0].split('=')[0]
                    val = line[0].split('=')[1]
                    param_dic[para] = val
                if 'movie_path' in param_dic:
                    sg_input = sg.Input(param_dic['movie_path'])
                else:
                    sg_input = sg.Input('')
            else:
                sg_input = sg.Input('')
            layout2 = [[sg.Text(text1, font=Font)], [sg_listbox,
                                                     sg.OK(u'下载')],
                       [sg.Text(u'下载路径', font=Font)],
                       [sg_input, sg.FolderBrowse(u'浏览')]]

            window2 = sg.Window(u'搜索结果').Layout(layout2)
            while 1:
                ev2, vals2 = window2.Read()
                if ev2 is None:
                    window2.Close()
                    break
                if len(vals2[0]) == 0:
                    sg.Popup(u'请选择一个电影', title=u'错误', font=Font)
                    continue
                # print(vals2[0][0])
                url = movie_dic[vals2[0][0]]
                # print(url)
                # print(vals2)
                movie_path = vals2[1]
                if len(movie_path) == 0:
                    sg.Popup(u'请输入下载路径', title=u'错误', font=Font)
                    continue
                # print(movie_path)
                config = open(os.getcwd() + '\\config.cfg', 'w')
                config.write('movie_path=' + movie_path + '\n')
                config.close()
                # sg_input.Update(movie_path)
                # movie_path = os.getcwd()+'\\'
                movie_path = movie_path + '/'

                print(movie_path)
                # exit()
                download_movies(url, movie_path)

        else:
            sg.Popup(u'无搜索结果,请检查关键词', title=u'错误', font=Font)

        if event1 is None:
            break
Beispiel #9
0
def download_movies(url, movie_path):
    '''
    :param url: 'http://532movie.bnu.edu.cn/player/3379.html'
    :return: None
    download *.ts to RAM
    write mp4 movie file to local disk from RAM
    '''
    temp_file = str(time.time())
    try:
        codecs.open(movie_path + temp_file, 'wb')
    except:
        sg.Popup(u'路径错误', font=Font)
        return None
    os.remove(movie_path + temp_file)
    movie_name, urls = get_vedio_url(url)
    invalid_char = '/\:*"<>|?'
    for ic in invalid_char:
        if ic in movie_name:
            movie_name = movie_name.replace(ic, '.')
    print(movie_name)
    # try:
    #     print(movie_name.decode('utf-8').encode('utf-8','ignore'))
    # except:
    #     print(movie_name.split()[0].decode('utf-8').encode('utf-8','ignore'))
    #
    try:
        movie_name_utf8 = movie_name.decode('utf-8').encode('gbk', 'ignore')
    except:
        movie_name_utf8 = movie_name.split()[0].decode('utf-8').encode(
            'gbk', 'ignore')
    episode = 0
    flag = 0
    # time_init = time.time()

    # time_start = time.time()
    if len(urls) == 1:
        if os.path.isfile(movie_path + movie_name.decode('utf-8') + '.mp4'):
            # print(movie_path + movie_name_utf8 + '.mp4 is already existed')
            sg.Popup(movie_path + movie_name.decode('utf-8') + u'已存在',
                     font=Font)
            return None
        ts = split_videos(urls[0])

        pool = ThreadPool(20)
        # bar_fmt = 'Downloading\t' + '|{bar}|{percentage:3.0f}%'
        results = list(tqdm_gui(pool.imap(download_ts, ts), total=len(ts)))
        plt.title('asdf')
        pool.close()
        pool.join()
        # print('Writing to disk...')
        movie = codecs.open(movie_path + movie_name_utf8 + '.mp4', 'wb')
        bar_fmt1 = 'writing to disk\t' + '|{bar}|{percentage:3.0f}%'
        for i in tqdm(range(len(results)), bar_format=bar_fmt1, ncols=50):
            movie.write(results[i])
        movie.close()

        plt.close()
        sg.Popup(u'下载完成!', title=u'完成', font=Font)

    else:

        # episode_str = raw_input(
        #     'there are %s episodes, please input a series of numbers like this(e.g.:1,10,15 or 1-3,4-10)' % len(urls))

        text = sg.Text(u'共有%s集\n请输入集数\n(例如:1,10,15 or 1-3,4-10)\n直接点击下载所有' %
                       len(urls),
                       auto_size_text=1,
                       font=Font)
        layout = [
            [text],
            [sg.Input(), sg.OK(u'下载')],
        ]
        window = sg.Window(u'选择集数').Layout(layout)
        while 1:

            ev, vals = window.Read()
            if ev is None:
                break
            # episodes = episode_str.split(',')
            print(vals)
            # continue
            if len(vals[0]) == 0:
                selected = range(1, len(urls) + 1)
            else:
                episodes = vals[0].split(',')

                selected = []
                fail1 = 0
                try:
                    for e in episodes:
                        if '-' in e:
                            e_split = e.split('-')
                            e_start = e_split[0]
                            e_end = e_split[1]
                            ee = range(int(e_start), int(e_end) + 1)
                            for ei in ee:
                                selected.append(ei)
                        else:
                            selected.append(int(e))
                except:
                    fail1 = 1

                selected.sort()
                for s in selected:
                    if s > len(urls):
                        print('there are no episode %s' % s)
                        fail1 = 1
                    elif s < 1:
                        print('input error...')
                        fail1 = 1
                if fail1 == 1:
                    sg.PopupError(u'输入有误', title=u'错误', font=Font)
                    continue

            # print selected
            # continue
            text2 = sg.Text('')
            layout2 = [
                [text2],
                [
                    sg.ProgressBar(len(selected),
                                   orientation='h',
                                   size=(20, 20),
                                   key='progressbar')
                ],
            ]
            window2 = sg.Window(u'下载进度').Layout(layout2)
            progress_bar = window2.FindElement('progressbar')

            flag1 = 0
            for i in urls:

                ev2, va2 = window2.Read(timeout=0)
                if ev2 is None:
                    break
                # selected_episodes = range(1, int(1e5))
                text2.Update(i)
                episode += 1
                if episode not in selected:
                    continue
                TV_dir = movie_path + movie_name_utf8 + '\\'
                if not os.path.isdir(TV_dir):
                    os.makedirs(TV_dir)
                if os.path.isfile(TV_dir + 'Episode ' + '%02d' % episode +
                                  '.mp4'):
                    # print(TV_dir + 'Episode ' + '%02d' % episode + '.mp4 is already existed')
                    flag += 1
                    # continue
                    sg.Popup(movie_name.decode('utf-8') + 'Episode ' +
                             '%02d' % episode + u'已存在',
                             font=Font)
                    continue
                pool = ThreadPool(20)
                ts = split_videos(i)
                bar_fmt = 'Episode %02d' % episode + '|{bar}|{percentage:3.0f}%'
                results = list(
                    tqdm_gui(pool.imap(download_ts, ts),
                             total=len(ts),
                             ncols=50,
                             bar_format=bar_fmt))
                pool.close()
                pool.join()
                plt.close()
                movie = codecs.open(
                    TV_dir + 'Episode ' + '%02d' % episode + '.mp4', 'wb')
                for r in results:
                    movie.write(r)
                progress_bar.UpdateBar(flag1 + 1)
                flag1 += 1
                window2.Close()