Author Topic: Script to mount DVD iso & play full screen  (Read 1971 times)

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Script to mount DVD iso & play full screen
« on: April 04, 2011, 02:33:29 AM »
I've taken to backing up all of my kids DVD's as ISO files, as they often damage and/or loose the discs.  In order to make those backups easily accessible for them to watch on the PC I wrote a short bash script. 

I hope others might also find it useful..  it is written so that it will handle file & directory names with spaces.  ;D

USAGE:
/path/to/script_name   "/path/to/iso_directory"   "/base/mount_directory"
Code: [Select]
play_iso  "$HOME/Movies"  "/mnt"


Here is the script:
(requires zenity, vlc, and kdesu/gksu..  I saved it as "play_iso")
Code: ("play_iso") [Select]
#!/bin/bash

path_to_isos="$1"
mnt_base_dir="$2"

# set Internal Field Separator to new line to avoid issues with spaces in paths
IFS="
"
for file in `find $path_to_isos -type f -iname "*.iso" 2>/dev/null`; do
  iso=$(basename "$file")
  iso_name=${iso%.*}
  iso_name_list+="${iso_name}\n"
done
unset IFS

echo -e "$iso_name_list"
usr_select=$(echo -e "$iso_name_list" | zenity --list --text "Which movie would you like to watch?" --column "Movie Title" )

[ "$usr_select" == "" ] && exit
echo "selected: $usr_select"

file_path=$( find $path_to_isos -type f -iname "${usr_select}.iso" 2>/dev/null )
mnt_path="${mnt_base_dir}/${usr_select}"
mysu=$( which kdesu || which gksu )
[ -d "${mnt_base_dir}/${usr_select}/VIDEO_TS" ] || $mysu -c "mkdir '$mnt_path';  mount -o loop '$file_path' '$mnt_path'" &>/dev/null 

[ -d "${mnt_base_dir}/${usr_select}/VIDEO_TS" ] && \
vlc -f "file://${mnt_path}" &>/dev/null || \
zenity --error --text "Unable to play movie.. \n...Ask Dad for help\!"








After saving the script some where in your $PATH (ie /usr/bin or $HOME/bin), set up a .desktop file / shortcut for easy access...

Code: ("Play Movie ISO.desktop") [Select]
[Desktop Entry]
Comment[en_US]=
Comment=
Exec=play_iso $HOME/Movies /media
GenericName[en_US]=Play ISO from Movie directory
GenericName=Play ISO from Movie directory
Icon=system-software-update
MimeType=
Name[en_US]=Play Movie ISO
Name=Play Movie ISO
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application


 ;)

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: Script to mount DVD iso & play full screen
« Reply #1 on: April 04, 2011, 02:41:51 AM »
I just set VLC as the default app to open ISOs when clicked on.

Thanks for posting the script  ;)

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3794
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: Script to mount DVD iso & play full screen
« Reply #2 on: April 04, 2011, 02:42:55 AM »
Looks cool...  ;)

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3794
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: Script to mount DVD iso & play full screen
« Reply #3 on: April 04, 2011, 02:44:54 AM »
I just set VLC as the default app to open ISOs when clicked on.

Thanks for posting the script  ;)

or can use smplayer, xt7-player etc.

But, i like the idea...

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Script to mount DVD iso & play full screen
« Reply #4 on: April 04, 2011, 02:48:32 AM »
I didn't know vlc or the others would open an iso without mounting first...  

 :o :-[

..guess I should have tried before wasting my time!
« Last Edit: April 04, 2011, 02:55:40 AM by travisn000 »

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3794
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: Script to mount DVD iso & play full screen
« Reply #5 on: April 04, 2011, 02:53:58 AM »
When ever i create a dvd.iso with dvdstyler, i use smplayer to see my output  ;).
But, dvd menu is not really correctly work in smplayer  ::)

Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11688
  • ----IOFLU----
Re: Script to mount DVD iso & play full screen
« Reply #6 on: April 04, 2011, 03:09:40 AM »
When ever i create a dvd.iso with dvdstyler, i use smplayer to see my output  ;).
But, dvd menu is not really correctly work in smplayer  ::)

Try Xine.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: Script to mount DVD iso & play full screen
« Reply #7 on: April 04, 2011, 03:42:19 AM »
When ever i create a dvd.iso with dvdstyler, i use smplayer to see my output  ;).
But, dvd menu is not really correctly work in smplayer  ::)

Yeah ......  which does not matter much in lots of cases, but I have videos of my own which have separate videos in the one ISO and SMPlayer does not allow selecting which to view from a menu.
VLC handles the menu well.

Xine does not open the ISO here for some reason, giving ......

Quote
                       - xine engine error -
           There is no demuxer plugin available to handle
            '/media/Data/ISOs/My-test-video.iso'
    Usually this means the file format was not recognized


Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11688
  • ----IOFLU----
Re: Script to mount DVD iso & play full screen
« Reply #8 on: April 04, 2011, 02:23:55 PM »

Xine does not open the ISO here for some reason.


Xine has a mind of it's own at times. I use the command line from within the directory housing the ISO image. The following works, but an alias saves a lot of typing

[prompt ]$ xine dvd:/$PWD/<name>.iso

To make it generic to be used with any ISO image, this works;

[prompt ]$ xine dvd:$PWD/$(basename *.[i-I][s-S][o-O])

I've aliased it with this line in my .alias file.

alias xd2='xine dvd:$PWD/$(basename *.[i-I][s-S][o-O])'

So now if I navigate into a directory with a movie ISO image all I type is xd2 to open the image at the menu level.

A second alias steps directly to the movie, skipping the menus.

alias xdm2='xine dvd:$PWD/$(basename *.[i-I][s-S][o-O])/1'

In KDE3 I made a menu entry, Xine DVD, so I could just click the image and Open With --> Xine DVD and set that as the default if I wanted a one click solution. The same entry doesn't work in KDE4, and I haven't found the correct command yet to use in a KDE4 menu entry. With the aliases still working, I haven't really looked very hard. ;D

If you don't have a separate ~/.alias file, you can add the above aliases to your ~/.bashrc, and they will then work from any new terminal opened after the .bashrc save.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: Script to mount DVD iso & play full screen
« Reply #9 on: April 04, 2011, 02:42:51 PM »
From the command line

xine dvd:/path-to-file.iso

works.  Just doesn't work in GUI apparently.

Oh well launching with VLC is easier  ;D

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: Script to mount DVD iso & play full screen
« Reply #10 on: April 05, 2011, 02:58:51 PM »
Just to add something here for anyone who might be interested ......

I added Xine to the right click menu item for ISOs.

The command is

Code: [Select]
xine dvd:%U
Video ISOs now launch perfectly in Xine for me without recourse to any terminal or particular workaround or setups.

regards.

Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11688
  • ----IOFLU----
Re: Script to mount DVD iso & play full screen
« Reply #11 on: April 05, 2011, 03:41:47 PM »
Just to add something here for anyone who might be interested ......

I added Xine to the right click menu item for ISOs.

The command is

Code: [Select]
xine dvd:%U
Video ISOs now launch perfectly in Xine for me without recourse to any terminal or particular workaround or setups.

regards.

The old KDE3 used the same but required a / and space before the %U. It still works with the / and no space;

xine dvd:/%U

to play the movie, without the menus;

xine dvd:%U/1

Also;

xine dvd:%f  =  Menu start

xine dvd:%F  =  Menu start

xine dvd:%u  =  Menu start

xine dvd:%U  =  Menu start

xine dvd:%f/1  =  Movie without menu

xine dvd:%F/1  =  Movie without menu

xine dvd:%u/1  =  Movie without menu

xine dvd:%U/1  =  Movie without menu

%U, %u, %F, %f all work.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...