91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.98KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2024-05-10
  • 語言: Python
  • 標簽: 下載??視頻??

資源簡介

網易云課堂的教學視頻進行下載

資源截圖

代碼片段和文件信息

#!C:\Python3.7
#?-*-?coding:utf-8?-*-

import?requests
import?os
from?threading?import?Thread
import?threading
import?optparse

sem?=?threading.Semaphore(100)
headers?=?{
????“User?-?Agent“:?“Mozilla?/?5.0(Windows?NT?10.0;WOW64)?AppleWebKit?/?537.36(KHTML?like?Gecko)?Chrome?/?84.0.4147.105?Safari?/?537.36“
????}

def?down_load_ts(urlpathname):
????basepath?=?os.path.join(os.getcwd()pathname)
????if?not?os.path.exists(basepath):
????????os.mkdir(basepath)


????try:
????????req?=?requests.get(urlheaders=headers)
????????#print(req.text)
????????file_line_list?=?req.text.split(‘\n‘)
????????if?not?“#EXTM3U“?in?file_line_list[0]:
????????????raise?baseException(u‘非M3U8的連接‘)
????????else:
????????????unknow?=?True
????????????file_index=100000
????????????for?indexline?in?enumerate(file_line_list):
????????????????if?“#EXTINF“?in?line:
????????????????????unknow?=?False
????????????????????url_ts?=?str(url).rsplit(‘/‘1)[0]?+‘/‘+?str(file_line_list[index+1])
????????????????????#下載文件名重新編號,以防合并是造成文件順序混亂
????????????????????file_name?=?str(file_index)+‘.ts‘
????????????????????file_index+=1
????????????????????full_file_name?=os.path.join(basepathfile_name)
????????????????????#?print(url_ts)

????????????????????process_ts(url_ts?full_file_name)

????????????????????#?t?=?Thread(target=process_tsargs=(url_tsfull_file_name))
????????????????????#?t.start()

????????????if?unknow:
????????????????raise?baseException(‘未找到對應的下載連接‘)
????????????else:
????????????????#?t.join()
????????????????print(pathname‘:downloaded‘)
????????????????print(“start?merge?file?to?mp4“)
????????????????mergeFileToMP4(pathname)
????????????????return


????except?Exception?as?e:
????????print(e)
????????return

def?process_ts(url_tsfull_file_name):
????with?sem:
????????req_ts?=?requests.get(url_ts?headers=headers)
????????print(“downloading?file:“?os.path.split(full_file_name)[1])
????????with?open(full_fil

評論

共有 條評論