Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   Video stream recording (http://stream-recorder.com/forum/forumdisplay.php?f=4)
-   -  

Python how to download protected files

(http://stream-recorder.com/forum/showthread.php?t=18927)

onodera 10-20-2014 04:29 AM

Python how to download protected files


 
I would like to download a "token" protected file and to use my cookie file in order to avoid multiple re-login. The way i proceed is as follow

First of all, import the cookie

Code:

import requests, cookielib

    cj = cookielib.MozillaCookieJar('cookies.txt')
    cj.load()
    r = requests.get(url, cookies=cj)

This is where i get a problem with, I must follow these steps in order to successfully download the desired file. (Everything in square brackets have to be replaced)

Code:

>> http://videoXXXXXXXX.fr/index.php?optio … &video_id=[VIDEO_ID]&load=1
Recover the cookie provided via "header set-cookie"
>> http://videoXXXXXXXX.fr/index.php?optio … &video_id=[VIDEO_ID]
Recover the "order_id" in the sent back page [ORDER_ID]
>> http://videoXXXXXXXX.fr/index.php?optio … &order_id=[ORDER_ID]
Recover the response token: [Token]
>> http://videoXXXXXXXX.fr/index.php?optio … raw&token=[Token]&order_id=[ORDER_ID]
This step allow the activation of the cookie recovered in step 1 as well as to obtain the complete file
>> http://videoXXXXXXXX.fr/picture_[VIDEO_ID].png

But the truth is, I would like some help in order to do all that in "Python"

Thank you in advance for your time, as well as your help.


All times are GMT -6. The time now is 07:17 AM.