This repository has been archived on 2024-07-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
WV-AMZN-4K-RIPPER/helpers/wvdownloader.pyc
T

93 lines
11 KiB
Plaintext
Raw Normal View History

2021-12-23 17:15:20 +05:30
a
ã@óêddlZddlZddlZddlZddlZddlZddlmZddlmZddl Z ddl
Z
ddl m m
Z
ddlmZddlmZddlmZmZddlmZmZmZmZmZGdd „d ƒZGd
d d ƒZGd d
d
ƒZGdddƒZdS)éÚdatetime©Úisfile©Úwvripper_config©Úaria2©Ú clean_audioÚ clean_mp4©Ú
DFXPConverterÚFixSubtitleTimeCodesÚReverseRtlStartEndÚ SDHConverterÚ
WebVTT2Srtc@óeZdZddZdddZdS)ÚTqdmcCót t¡|_dS)ÚloggingÚ getLoggerÚ__name__Úlogger©Úself©rúhelpers\wvdownloader.pyÚ__init__óú
Tqdm.__init__NFc Có–|r|nt}|j|dd}t|jdƒ}d}d} t|| ƒ}
t|dƒ<} tj|j| d|
d|dd D]}|  |¡qdWd
ƒn1sˆ0Yd
S) ú3Simpt Python downloader Using tqdm for progress barT©ÚstreamúContent-LengthééÚwb©Ú
chunk_sizeÚKB©ÚtotalÚunitÚdescÚleaveN©ÚrequestsÚgetÚintÚheadersÚopenÚtqdmÚ iter_contentÚwrite© rÚUrlÚOutputÚproxiesÚsessionÚrÚ file_sizeÚchunkr,Znum_barsÚfprrrÚDownLoadó    
û
*ú
Tqdm.DownLoad©NF©rÚ
__module__Ú __qualname__r rFrrrrrórc@ó:eZdZddZddZddZddgdddfdd „Zd
S) ÚAria2ccCót t¡|_dS)Nrrrrrr 1óúAria2c.__init__cCóH|jr(tƒ}|j|jj|j|jddStƒ}| |jj|j|j¡dS)r@© Únoaria2crrFÚTrackr=r>Ú tqdm_sessionr
Úextra_commands©rZTqdm_ÚAr2rrrÚUrlType4óúAria2c.UrlTypecCóV|jr,|j d¡tdƒ ¡}| d¡r,dStƒ}| |jpB|j j
|j |j |j
¡dS)Nú.<noaria2c> does not works with DASH downloads.ú,Do you want to use aria2c for downloading?: ÚrVrÚinfoÚinputÚstripÚ
startswithr
ÚDashÚsegmentsrWÚSegmentsr>rYÚfixbytes©rZconfirm_using_aria2c_insteadr[rrrÚDashType@ó ÿ
 úAria2c.DashTypeFc Cóš||_||_||_||_||_||_||_t|jtƒr<i|_t |jƒrXt d|jƒsXdS|j
  d|j¡|jj dkr| 
¡n|jj dkr| ¡dS)áÎ
@Output: Output filename.
@Track: Track attributes.
@noaria2c: do not use aria2c as main downloader, use tqdm: only for URL Type.
@fixbytes: fix bytes for appletv atmos audios.
@extra_commands: aria2c extra commands or proxies.
@segments: will force use this segments instead of track.Segments: only for DASH type.
@tqdm_session: add request session for tqdm downloader: only for URL type.
ú%s.aria2Nú
Downloading: ÚURLÚDASH©r>rWrVrYrkrirXÚ
isinstanceÚlistrrrdÚ DownloadTyper\rm© rr>rWrVrkrYrirXÚquietrrrrFOó"  
 úAria2c.DownLoadN©rrKrLr r\rmrFrrrrrO0ó ÷rOc@óXeZdZddZdddZddZdd „Zd
d Zdd d
ZddZ ddZ
ddZ dS)Ú VideoHelpercCó$t t¡|_tƒ|_|j ¡|_dS)ú?VideoHelper: Hold the functions for decrypt/clean/demux videos.N©rrrrrÚconfigrrrrr |ó úVideoHelper.__init__TcCóBg}|D]4}| d¡| d |r*|dn|d|d¡¡q|S)--keyú{}:{}ÚKIDÚIDÚKEY©ÚappendÚformat©rÚdecryptionKeysÚkidÚkeysÚkeyrrrÚ
getKeysMp4ó

(úVideoHelper.getKeysMp4cCó2g}|D]$}| d¡| d |dd¡¡q|S)--keysúkey={}:key_id={}rÚ 00000000000000000000000000000000rŽ©rrr”r•rrrÚ getKeysShakaó
ÿÿúVideoHelper.getKeysShakac
Có~|j d |¡¡|j d dd|Dƒ¡¡t |jjjddd |||¡g|  |¡¡}| 
¡\}}|  ¡|j d¡dS) Nú
Decrypting: {}Ú
cSó g|]}d |d|d¡qS)rr©r©Ú.0ÚxrrrÚ
<listcomp>šóú.VideoHelper.shakadecryptor.<locals>.<listcomp>ú--enable_raw_key_decryptionú-quietúinput={},stream={},output={}úDone!© rrdrÚjoinÚ
subprocessÚPopenr…ÚBINÚshaka_packagerržÚ communicateÚwait©rÚ encryptedÚ decryptedr”r&Úwvdecrypt_processÚ
stdoutdataÚ
stderrdatarrrÚshakadecryptor˜ó üúÿ
 úVideoHelper.shakadecryptorcCóžtj|tjtjddd}d}d}t|dƒD]P}| ¡}d|vrHt|ƒq*d|vr`t|ddd q*d
|vrnd}q*d |vr*|}q*tƒ|rŽtd
ƒ|ršt|ƒdS) Nr(ÚstdoutÚstderrÚbufsizeÚuniversal_newlinesFrÃúStarting Decryptionú
©ÚflushÚendúDecrypted successfullyúDecryption took©ÚPIPEÚSTDOUTÚgetattrrfÚprint©rÚcommandÚprocZDecrypted_successfullyZDecrypted_tookÚlinerrrÚrunpandsdecryptor«ó2û
úVideoHelper.runpandsdecryptorc
CóØ|j d |¡¡|j d dd|Dƒ¡¡tƒ|rB|jjjn|jjjg|j ||dd||g}t
j ddkrŒt j
|t jt jd dS|rª| |¡|j d
¡dSt  |¡}| ¡\}} | ¡|j d
¡dS) Nr¢cSó g|]}d |d|d¡qS)rrrrrËú,VideoHelper.mp4decryptor.<locals>.<listcomp>©r“ú--show-progressÚ THREAD_MODEÚYES©©rrdrr…r´ÚpandsdecryptorÚ
mp4decryptrÚosÚenvironr²ÚcallÚDEVNULLrØ©
rr”r“Zdecrypt_commandr»rrrÚ mp4decryptorÉó0ÿ ý ûúÿ

 
  úVideoHelper.mp4decryptorcCó<|j d |¡¡t|jjj||ƒ}| ¡|j d¡dS)
Cleaning: {}r¯©rrdrr
r…r´ÚffmpegÚstart_cleaning©rÚcleanedrñrrrÚ ffmpegcleanèóúVideoHelper.ffmpegcleanc Có@|j d |¡¡t |jjjdddd||g¡|j d¡dS)Nrïr­ú-rawÚ-outr¯©rrdrr…r´Úmp4box©rrrrÚ
mp4boxegcleanîó
ÿúVideoHelper.mp4boxegcleancCóbt|jjj|ƒ}| |jjj¡}| |¡}t|ƒr6dS|j  d 
|¡¡|  |¡|j  d¡dS)Nrï© r r…Ú
mediainfo_Ú MediaInfoÚ
set_Outputrrrdr©rÚInputrñÚ mediainfor>rrrÚffmpegcleanAudioõó

 úVideoHelper.ffmpegcleanAudioN©TT© rrKrLr rrÿr
rrrrr{ó


rc@ó´eZdZddZdddZd ddZdiiifd d
Zd!eed œd
dZd"eed œddZ d#eed œddZ