LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to write a script to rip a season of DVDs? (https://www.linuxquestions.org/questions/programming-9/how-to-write-a-script-to-rip-a-season-of-dvds-685458/)

TheMusicGuy 11-22-2008 08:14 PM

How to write a script to rip a season of DVDs?
 
Hi,

I'm going to try to find the answer to this on my own, but in the mean time I want to know if somebody has already come up with a way to do this.

I want to write a shell script to rip a season of a TV shows that I have on DVD using Handbrake CLI. Also, I want to run each ripped file through a special CLI-based converter (which I already have) so I can watch them on my DS.

The basic format of the shell script would be something like
Code:

ripseason.sh %F_%S_%E.mp4 NUM_DVDS NUM_TITLES_PER_DVD
Where %F is replaced with the name of the series, %S is replaced with the season number, and %E is replaced with the number of the episode in the season.

I already know how to use handbrake CLI and have ripped one whole season but it was tedious and involved a lot of manual intervention. I would like to have a single command to rip subsequent seasons of this show (and others) but I don't know hardly anything about shell scripting except the very basics (cp, rm, ls, mv, how to pipe output, how to set environment variables, etc.). This script would have to be able to stop and wait for the user to switch DVDs after each one was ripped and then wait for a keypress or something to continue.

If anyone knows of a script like this or can at least point me to someplace where I can learn how to write one that would be great. Thanks!

ErV 11-22-2008 08:30 PM

Quote:

Originally Posted by TheMusicGuy (Post 3351425)
Hi,
If anyone knows of a script like this or can at least point me to someplace where I can learn how to write one that would be great. Thanks!

Can be done in python within half-hour in a bit simplified form.

Except one thing:
Quote:

Originally Posted by TheMusicGuy (Post 3351425)
Where %F is replaced with the name of the series,

name of the series will have to be user-provided.

Try to read python tutorial, or take any simple shell script (slackware has bunch of them) and examine it. People often write scripts like that and delete them when they are no longer needed, because such scripts are simple. So I'm not sure if something like this will be available for download somewhere, but someone might write that script for you.

TheMusicGuy 11-22-2008 10:02 PM

This is going to sound odd, but I wanted to see if/how it could be done using only Bash because using Python feels like cheating. That's the main reason I didn't try it already! ^_^

johnson_steve 11-23-2008 12:32 AM

Quote:

Originally Posted by TheMusicGuy (Post 3351483)
This is going to sound odd, but I wanted to see if/how it could be done using only Bash because using Python feels like cheating. That's the main reason I didn't try it already! ^_^

I hope something gets posted here so I can see how it works an use it in my own bash scripts. I don't know any python.

unihiekka 11-23-2008 02:54 AM

Quote:

using only Bash because using Python feels like cheating
Why? If Python does the job, it does it. No cheating involved!

TheMusicGuy 11-23-2008 03:28 AM

I knew somebody was going to ask that...well, the truth is I don't really know. I guess part of the reason I wanted to do this was so that I could use this as an opportunity to learn how to use Bash better? I already know Python fairly well, and this sort of thing doesn't really require the job of a high-level language like Python as it is basically (I am assuming) just a few loops, a process fork, and some shell commands.

Anyway, though, I've already started on a Python script, but it seems that it's going to take longer than I thought because I won't get a chance to work on it for it until a few days from now. Possibly. But still, I'd like the learning experience of doing it in Shell, so if anyone has an inkling of where one would begin, I'm still open to suggestions...


All times are GMT -5. The time now is 05:30 PM.