K-S-V / Scripts

Collection of my scripts
GNU General Public License v3.0
634 stars 226 forks source link

AdobeHDS.php sends no query string for fragments #69

Closed p-u-m-a closed 8 years ago

p-u-m-a commented 8 years ago

I was able to successfully download an Akamai DRM encrypted video, but requiring a small modification to AdobeHDS.php. Are you able to find the problem in the code so that this modification is no more needed?

The Manifest is successfully downloaded, but Fragment 1 fails. Sniffing HTTP transactions from both the original website and AdobeHDS.php, I noticed AdobeHDS.php sends no query string with the fragment request, but the original website does.

My fix was to manually copy just the pvtoken parameter of Fragment 2 from the website, and add it to every URL generated by AdobeHDS.php.

I.e., given this request for Fragment 2 from original website:

GET /z/docev/2016/docev_20160113_standard_DOCEV_2016-01-13T201500_Asset00_101109-,101,301,701,1201,k.mp4.csmil/3_6b2ff5ecca11e4fd_Seg1-Frag2_AQAfCpzzAhYIRwaToFaTflbdH29WPZ0CyzSXpJozcuqKg3xm62U4LZ5Zz7CgB0lXyimtaFfz**?pvtoken**=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0NTM0NTAzNzJ+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPTViZDg0YjlkNjNjMjg4YjFmZGI1NWRhNzlhMzI0ZmVhMzVlM2Q0ZmYyYWE0YjA4NzVlYjExMjYwZmE0NDM1MmU%3D%21uPh3SVIi1cGo1lU6lZ/Yb9uPMdM1NDxHuH/x0rp58As%3D%7Ehmac%3D2F86C6E2D72ACA17C75A41DC30083C4930414BE27C47B16D5412F6BA55A2C0AA&hdntl=exp=1453450372~acl=%2fz%2fdocev%2f2016%2fdocev_20160113_standard_DOCEV_2016-01-13T201500_Asset00_101109-,101,301,701,1201,k.mp4.csmil%2f*~data=hdntl~hmac=65b0c76c2a69f42bb705c73fe6b1e1ffa210a8f43b26022a69f3cccc6327a9b2&als=6.42,30,NaN,3,1505,102140,0,0,0,81,t,0.17,9555.28,f,s,FVJHMKDKNMFV,3.4.0,81&hdcore=3.4.0&plugin=aasp-3.4.0.132.66 HTTP/1.1

…add this on line 692:

if (empty($mediaEntry['queryString'])) {
    $mediaEntry['queryString'] = '?pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0NTM0NTAzNzJ+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPTViZDg0YjlkNjNjMjg4YjFmZGI1NWRhNzlhMzI0ZmVhMzVlM2Q0ZmYyYWE0YjA4NzVlYjExMjYwZmE0NDM1MmU%3D%21uPh3SVIi1cGo1lU6lZ/Yb9uPMdM1NDxHuH/x0rp58As%3D%7Ehmac%3D2F86C6E2D72ACA17C75A41DC30083C4930414BE27C47B16D5412F6BA55A2C0AA';
}

More details for debugging, and let me know if you need something else:

$ php56 AdobeHDS.php --manifest 'http://rtsch-f.akamaihd.net/z/docev/2016/docev_20160113_standard_DOCEV_2016-01-13T201500_Asset00_101109-,101,301,701,1201,k.mp4.csmil/manifest.f4m?hdnts=exp=1453366522~acl=/z/docev/2016/docev_20160113_standard_DOCEV_2016-01-13T201500_Asset00_101109-,101,301,701,1201,k.mp4.csmil/*~hmac=a53abcd28da0158ac6727832520b57785bcde7094607aa096b010c32c990cf7e&g=REEOCGEWEZUU&hdcore=3.4.0&plugin=aasp-3.4.0.132.66' --useragent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36' --delete --debug

                            KSV Adobe HDS Downloader

Processing manifest info....                                                   
Manifest Entries:

 Bitrate URL
 1324    3_6b2ff5ecca11e4fd_
 661     2_6b2ff5ecca11e4fd_
 346     1_6b2ff5ecca11e4fd_
 146     0_6b2ff5ecca11e4fd_

Quality Selection:                                                             
 Available: 1324 661 346 146
 Selected : 1324                                                               
Segment Tables:

Table 1:
 Number  Fragments 
 1       1592      

Fragment Tables:

Table 1:
 Number      Timestamp       Duration        Discontinuity   
 1           0               6000                            
 1592        9546000         9313                            
 0           0               0               0               

Fragments Total: 1592, First: 1, Start: 1, Parallel: 8                         
Base Fragment Url:
http://rtsch-f.akamaihd.net/z/docev/2016/docev_20160113_standard_DOCEV_2016-01-13T201500_Asset00_101109-,101,301,701,1201,k.mp4.csmil/3_6b2ff5ecca11e4fd_

Downloading Fragments:

Adding fragment 1 to download queue                                            
Access Denied! Unable to download fragments.                                   
K-S-V commented 8 years ago

What you are trying to do is already supported by AdobeHDS script. look at the --auth switch in the wiki. if you use the "HDS Link Detector" add-on then it can automatically grab the required parameters.

p-u-m-a commented 8 years ago

Thanks for explanations @K-S-V. I read the wiki before, but too fast I guess.

I added a Troubleshooting section in the wiki about this. Hopefully, it will be useful to other users.