#!/usr/bin/env python__all__ = [' Pptv_download ', ' pptv_download_by_id ']from. Common import *import reimport timeimport urllibfrom random import randomdef Constructkey (ARG): Def str2hex (s): R= "" For I in S[:8]: T=hex (ord (i)) [2:] If Len (t) ==1:t= "0" +t r+=t For I in range: R+=hex (Int. (15*random ())) [2:] return R #ABANDONED Because Server_key is STA Tic def getkey (s): #returns 1896220160 l2=[i for i under s] l4=0 l3=0 while L4
>> in AS3 if K>=0:return k>>b elif k<0:return (2**32+k) >>b Pass def Lot (k,b): Return (k<
([^<>]+)', XML) K = R1 (R '
]+> ([^<>]+)
', XML) RID = R1 (R ' rid= "([^"]+) "', XML) title = R1 (R ' nm=" ([^ "]+)" ', XML) ST=R1 (R '
([^<>]+)
', XML) [: -4] St=time.mktime (Time.strptime (ST)) *1000-60*1000-time.time () *1000th+=time.time () *1000th=st/1000 ke Y=constructkey (st) pieces = Re.findall ('
<>]+fs= "(\d+)" ', XML) numbers, FS = Zip (*pieces) urls=["Http://{}/{}/{}?key={}&fpp.ver=1.3.0.4&k={}&type=w EB.FPP ". Format (host,i,rid,key,k) for I in range (max (map (int,numbers)) +1)] total_size = SUM (map (int, FS)) Assert RID. EndsWith ('. mp4 ') Print_info (Site_info, title, ' mp4 ', total_size) if not Info_only:try:download_u RLS (URLs, title, ' mp4 ', total_size, Output_dir = output_dir, merge = merge) except Urllib.error.HTTPError: #for Key expired pptv_download_by_id (ID, output_dir = output_dir, merge = merge, Info_only = info_only) def p Ptv_download (URL, output_dir = '. ', merge = True, info_only = False, **kwargs): Assert Re.match (R ' Http://v.pptv.com/sho w/(\w+) \.html$ ', url) html = get_html (URL) id = R1 (R ' webcfg\s*=\s*{"id": \s* (\d+) ', HTML) assert ID Pptv_downlo ad_by_id (id, output_dir = output_dir, merge = merge, info_only = info_only)
Reply content:
#!/usr/bin/env python__all__ = [' Pptv_download ', ' pptv_download_by_id ']from. Common import *import reimport timeimport urllibfrom random import randomdef Constructkey (ARG): Def str2hex (s): R= "" For I in S[:8]: T=hex (ord (i)) [2:] If Len (t) ==1:t= "0" +t r+=t For I in range: R+=hex (Int. (15*random ())) [2:] return R #ABANDONED Because Server_key is STA Tic def getkey (s): #returns 1896220160 l2=[i for i under s] l4=0 l3=0 while L4
>> in AS3 if K>=0:return k>>b elif k<0:return (2**32+k) >>b Pass def Lot (k,b): Return (k<
([^<>]+)', XML) K = R1 (R '
]+> ([^<>]+)
', XML) RID = R1 (R ' rid= "([^"]+) "', XML) title = R1 (R ' nm=" ([^ "]+)" ', XML) ST=R1 (R '
([^<>]+)
', XML) [: -4] St=time.mktime (Time.strptime (ST)) *1000-60*1000-time.time () *1000th+=time.time () *1000th=st/1000 ke Y=constructkey (st) pieces = Re.findall ('
]+fs= "(\d+)" ', XML) numbers, FS = Zip (*pieces) urls=["http://{}/{}/{}?key={}&fpp.ver=1.3.0 .4&K={}&TYPE=WEB.FPP ". Format (host,i,rid,key,k) for I in range (max (map (int,numbers)) +1)] total_size = SUM (Map ( int, FS)) Assert Rid.endswith ('. mp4 ') Print_info (Site_info, title, ' mp4 ', total_size) if not info_only:tr Y:download_urls (URLs, title, ' mp4 ', total_size, Output_dir = output_dir, merge = merge) except URLLIB.E Rror. Httperror: #for key expired pptv_download_by_id (ID, output_dir = output_dir, merge = merge, info_onl y = info_only) def pptv_download (url, output_dir = '. ', merge = True, info_only = False, **kwargs): Assert Re.match (R ' HT tp://v.pptv.com/show/(\w+) \.html$ ', url) html = get_html (URL) id = R1 (R ' webcfg\s*=\s*{"id": \s* (\d+) ', HTML) Asser T ID pptv_download_by_id (ID, output_dir = output_dir, merge = merge, info_only = info_only)