zoukankan      html  css  js  c++  java
  • BCC Learning English MP4 Download

    写了一个小程序,存档如下:

    import time
    import threading
    import os
    import urllib

    def get_now_time_str():
        now_time = time.localtime()
        now_str = time.strftime("%Y-%m-%d  %H:%M:%S   ",now_time)
        return now_str

    class FileDownload(threading.Thread):
        
        def start_download(self, file_url, file_path):
            self.file_url = file_url
            self.file_path = file_path
            self.start()
               
        def run(self):
            self.download_file(self.file_url,self.file_path)
        
        def download_file(self,file_url,file_path):
            if(os.access(file_path,os.F_OK)):
                print get_now_time_str() + file_path + " was Existed!"
            else:
                urllib.urlretrieve(file_url, file_path)
                print get_now_time_str() + file_path + " was downloaded completely"

    #http://downloads.bbc.co.uk/worldservice/learningenglish/pronunciation/mp4/vowel_long_2.mp4
    BBCLearningEnglishDownload = "http://downloads.bbc.co.uk/worldservice/learningenglish/pronunciation/mp4/"

    def make_file_names_list():
        file_name_list = []
        for i in range(7):
            file_name = "vowel_short_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)
            
        for i in range(5):
            file_name = "vowel_long_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)
            
        for i in range(8):
            file_name = "vowel_dip_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)
            
        for i in range(8):
            file_name = "con_voiceless_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)

        for i in range(8):
            file_name = "con_voiced_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)

        for i in range(8):
            file_name = "con_other_" + str(i + 1) + ".mp4"
            file_name_list.append(file_name)
        
        return file_name_list

    FilePath = "./pronunciation/"
    if not os.path.exists(FilePath):
        os.makedirs(FilePath)

    print "Download short vowel"
    for file_name in make_file_names_list():
        file_url = BBCLearningEnglishDownload + file_name
        file_path = FilePath + file_name
        FileDownload().start_download(file_url, file_path)

     

  • 相关阅读:
    Webpack4 入门手册(共 18 章)下
    npm(Node Package Manager)
    C#(99):C# 5.0 新特性(.NET Framework 4.5 与 Visual Studio 2012 )
    C#(99):四、Async和Await使异步编程更简单
    C#(99):三、.NET 4.0基于任务的异步模式(TAP),推荐使用
    C#(99):二、.NET 2.0基于事件的异步编程模式(EAP)
    C#(99):一、.NET 1.0 异步编程模型(APM)
    VS中的代码段功能
    VS在C#类文件头部添加文件注释的方法
    C#(99):C# 语言历史版本特性(C# 1.0到C# 8.0汇总)
  • 原文地址:https://www.cnblogs.com/huangliujing/p/1616342.html
Copyright © 2011-2022 走看看