Downloading Multiple Videos using FOR Loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Downloading Multiple Videos using FOR Loop
# 1  
Old 02-01-2013
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.
# 2  
Old 02-01-2013
try: http://user:pass@hostname.com/blah/blah
# 3  
Old 02-01-2013
Code:
wget --post-data="username=artiomix&amp;pwd=yourpassword" --cookies=on --keep-session-cookies --save-cookies=cookie.txt "http://www.website.com/member.aspx"

then

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

# 4  
Old 02-02-2013
If wget does not work, you my try curl
# 5  
Old 02-04-2013
This was suggest as well:

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.

per:
Downloading Multiple Videos using FOR Loop
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Multiple if within while loop ksh

Hi All, I'm trying to write while loop with multiple if conditions. Each and every if condition with different variables. whenever one if condition fails i have remove the file from filename and have to pick another file and loop should exit until the last file found in filename. Please help... (4 Replies)
Discussion started by: Kayal
4 Replies

2. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

3. Shell Programming and Scripting

Multiple IP Loop

Hey all, I'm trying to do some very basic scripting. I been scouring the board looking at examples but I just can't seem to piece something together. Edit: Now that I look at it, maybe my request is a little more complex and I'm biting off more than I can chew... 1. Take a list of... (3 Replies)
Discussion started by: YouFatPenguine
3 Replies

4. Shell Programming and Scripting

Doing multiple tasks in a loop.

I am in the process of updating a folder of hundreds of recipe html files. I've already managed to modify a number of things in each file but I have run into something that's beyond my ability. I have a text file that I need to insert the contents into the html at a specific point. It creates... (0 Replies)
Discussion started by: Trapper
0 Replies

5. Shell Programming and Scripting

How to avoid multiple while loop?

Hi, How can I avoid multiple 'cat while read ....? in my script. In my script, I am taking the inputs from the temp text file and doing the ( cat while read input do ... ... done ) task and deleting later. I know it'll raise the perfomance issue. How to avoid this? (2 Replies)
Discussion started by: sharif
2 Replies

6. Shell Programming and Scripting

please help in multiple for loop

Hi I have these data 0.9>i>0.1 0.45>j>0.01 I want to execute the script file for different number of i and j using the command $ ./scriptfile i j I write this code #bin/bash for ((i>0.1; i<0.9; i++)) for ((j>0.01; j<0.45; j++)) do ./scriptfile $i $j done However, for loop is not... (3 Replies)
Discussion started by: snow
3 Replies

7. Shell Programming and Scripting

Multiple conditionals in a while loop

Hi was wonderring about the syntax for the following peice of code: while ] ; do This is apparently incorrect. I want the loop to continue WHILE $life is not equal to zero or $mask is not equal to $word. Should ONE of these conditions fail to be met, loop should break out. Any ideas? ... (8 Replies)
Discussion started by: santeria
8 Replies

8. Shell Programming and Scripting

While loop with Multiple variables

Hi , I am trying to write a script in kshell with while loop ,its like count=1 count_cmp=1 while ; do tail -$count tempfile | head -1 > tempstring ....... done However i get CIF.sh: line 33: ' I have checked thetrailing spaces , not sure what is... (4 Replies)
Discussion started by: amit1_x
4 Replies
Login or Register to Ask a Question