LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Downloading Multiple Videos using FOR Loop (https://www.linuxquestions.org/questions/linux-software-2/downloading-multiple-videos-using-for-loop-4175448242/)

metallica1973 02-01-2013 04:43 PM

Downloading Multiple Videos using FOR Loop
 
Scenario:

I watch computer based on-line tutorials via a site that uses ASP that allows downloading of their content. When I login and I look at the cookie, I can see that is uses a "AspSessionIdCopy" and a value"

"325434f6-57b2-4b65-8374-blahblahblah"

When I am looking at each video of the course that I am watching I can see that the link is the same with only the number incrementing such as:

Code:

http://www.website.com/home/Player.aspx?lpk4=108148&playChapter=False
http://www.website.com/home/Player.aspx?lpk4=108149&playChapter=False
http://www.website.com/home/Player.aspx?lpk4=108149&playChapter=False

So what I would like to do, is just download the videos using a "for" loop and watch them locally on my laptop at my leisure. Once I know the sequence of numbers of the series, I would proceed in downloading the content. This is my method I will use:
Code:

#!/bin/bash
for (( a=56; a<=96; a++ ))
do
    wget -c http://www.website.com/home/Player.aspx?lpk4=10814$a&playChapter=False
done

My question is that I can see that I will have to use authentication on order to be able to do this from the cli and thats the part that I cannot figure out. What is the correct syntax using wget with authentication:

Code:

wget -c username:password@http://www.website.com/home/Player.aspx?lpk4=10814$a&playChapter=False
or

adding to cookies.txt:

Code:

"AspSessionIdCopy 325434f6-57b2-4b65-8374-37ca1ec6ad9f"
Code:

#!/bin/bash
for (( a=56; a<=96; a++ ))
do
wget -c --load-cookies cookies.txt username:password@http://www.website.com/home/Player.aspx?lpk4=10814$a&playChapter=False
done

and download the context that I want. Will this work.

or maybe:

Code:

wget --post-data="username=artiomix&amp;pwd=yourpassword" --cookies=on --keep-session-cookies --save-cookies=cookie.txt "http://www.website.com/member.aspx"
or

Code:

wget --referer="http://www.website.com/members.aspx" --cookies=on --keep-session-cookies --load-cookies=cookie.txt http://www.website.com/home/Player.aspx?lpk4=108148&playChapter=False

H_TeXMeX_H 02-02-2013 09:30 AM

In the past I have done something like:

Code:

useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1"
cookie="Cookie: user=?????????????"

wget -c --no-cookies --header "$cookie" --user-agent="$useragent"

You will have to check the cookies and see what you need for it. You may also want to consider using the '--wait=' and the '--random-wait' options in case they monitor behavior and may suspect you are a bot.

chrism01 02-03-2013 07:27 PM

For embedded vars, you should use {} to enable the parser to recognise it
Code:

...10814${a}&playChapter...

metallica1973 02-04-2013 03:03 PM

Many thanks for all the replies. I will give this a shot tonight and give you some feedback soon.


All times are GMT -5. The time now is 06:26 PM.