LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-01-2013, 04:43 PM   #1
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,113

Rep: Reputation: 57
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

Last edited by metallica1973; 02-01-2013 at 05:01 PM.
 
Old 02-02-2013, 09:30 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
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.
 
Old 02-03-2013, 07:27 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,246

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
For embedded vars, you should use {} to enable the parser to recognise it
Code:
...10814${a}&playChapter...
 
Old 02-04-2013, 03:03 PM   #4
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,113

Original Poster
Rep: Reputation: 57
Many thanks for all the replies. I will give this a shot tonight and give you some feedback soon.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Question(for loop): How to Zip multiple files under multiple directories Znrall Linux - General 2 08-01-2012 01:52 PM
LXer: Downloading all videos of an youtube user, from the terminal LXer Syndicated Linux News 0 01-15-2011 07:42 PM
[SOLVED] Is there a tool for downloading youtube videos? mark_alfred Linux - Software 2 04-13-2010 10:52 PM
downloading flash videos fakie_flip Linux - Software 5 09-16-2006 09:57 PM
Downloading Google Videos? aquaboot Ubuntu 14 09-10-2006 09:56 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration