Sponsored Content
Top Forums Shell Programming and Scripting Looking for help with a script to automate VLC Post 302321119 by uncertain on Saturday 30th of May 2009 08:22:35 AM
Old 05-30-2009
Looking for help with a script to automate VLC

Hi,
New member here looking for help. This might not be a post for the 'VERY basics' section, so feel free to move it to somewhere more appropriate.

I've created a script that searches my computer for video files, creates a list of these files, and selects a number of random entries to play in VLC. After a recent catastrophic external HDD failure, everything I could recover has been moved to two computers on a LAN. Now, instead of just searching my ~/Videos folder for the files to index and play, I have to search the ~/Videos folder of a second computer as well, index those (appended to the same list, preferably), and include them in the random shuffle I've created.

I have SSH & SCP access on both machines (I recently learned how to implement passwordless-ssh using rsa & dsa keyfiles, specifically so these processes could be automated). I don't have Samba or NFS installed or working on either computer, but I'll install and configure them if need be. (Though I'd rather not install, configure, and enable NFS or Samba, edit fstab, and then auto-mount a remote folder at boot just to do this.) Just today, I've learned how to start VLC on the remote computer in network-streaming mode, and then start VLC on the local host in network-capture mode. All I'm having a hard time conceptualizing is how to implement the indexing process from a script on the local machine to list files on a remote machine.

Here's a copy of my script in its' current state. It's the first BASH scripting project I ever tackled, and 'borrowed' bits & pieces of it from various things I found via Google. I'm sure there's a better/smoother/cleaner way to do some of the things I did, but it works, and I'm happy with it. Right now, it's set to index all the episodes of The Simpsons that are in my hard drive, and then play several random episodes.

If anyone could point me in a direction or give me some pointers, I'd greatly appreciate it.
Code:
#!/bin/bash
#
# Creates a list of all files in all Simpsons folders and then
# plays so many random episodes with VLC Media Player.
# Created by Uncertain

# Filenames and paths.
path1=/home/zero/Videos/
path2=/home/zero/Videos/Simpsons
list=/home/zero/Videos/Simpsons/episodes.txt
# Check for the list. If it's in ~/Videos, fine.
# If it doesn't exist, create it in ~/Videos.
if [ -f $list ]
 then
  echo "List found at $list"
   else
    echo "Episodes list not found. Creating list arranged by season & episode..." && cd $path1 && find ~/Videos/Simpsons -name '*.avi' -o -name '*.mpg' -o -name '*.mp4' -o -type f -size +20M | sort > $list && echo "Done. List created at: $list" 
fi
# Set the number of episodes to play. Episodes are 
# roughly 20 mins, so three episodes to every hour.
repeat=3
cycles=0
while  [ $cycles -ne $repeat ]
 do
  echo $cycles
  cycles=$(( $cycles + 1 ))
# Read the list, select one random line.
LowerBound=1
RandomMax=32767
UpperBound=$(cat $list | wc -l)
RandomLine=$(( $LowerBound + ($UpperBound * $RANDOM) / ($RandomMax + 1) ))
# Use sed to grab the random line.
episode=$(sed -n "$RandomLine{p;q;}" "$list")
# open the random line in VLC
vlc -vvv --fullscreen "$episode" vlc:quit
# Close the episode count loop...
  done
# ...and then...
exit


Last edited by uncertain; 05-30-2009 at 10:43 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

automate the input in a script

I have a program that i have to run by cron. The program needs user input. So i have to automate that in a littke script. start of script program.sh: result=program.log; export result echo Program starting : `date` >> $result /usr/local/program >> $result echo Program running : `date` >>... (11 Replies)
Discussion started by: erwinspeybroeck
11 Replies

2. Shell Programming and Scripting

here document to automate perl script that call script

I am trying to use a here document to automate testing a perl script however when the perl script hits a system(perl subscript.pl) call, input is no longer entered into this subscript. here is my script $ cat test.sh #ksh for testcase do program <<-EOF | tee -a funcscnlog.log y... (3 Replies)
Discussion started by: hogger84
3 Replies

3. Shell Programming and Scripting

Script(s) to Automate Tasks

I know that this has a bad title, but I'm not sure how to sum it up well. (And I'm new to Linux in general, so please excuse any incorrect terminology :o) Anyway, I'm trying to create a script that gets whatever folder you're in, and then does a command with that directory as an argument. I... (2 Replies)
Discussion started by: droppedonjapan
2 Replies

4. UNIX for Advanced & Expert Users

Shell Script to Automate

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (1 Reply)
Discussion started by: sam786
1 Replies

5. Shell Programming and Scripting

Automate shell script

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (3 Replies)
Discussion started by: sam786
3 Replies

6. Shell Programming and Scripting

Automate Script ***V. Urgent

Hi All, ./procdure.ksh which opens the below the menu, I want to build a script which will press 4 and run the Sector Data Automatically (instead of pressing option 4 manually) Is there any way for this, please let me know... 1) FX Rates MDU 9) Fidessa Cash... (7 Replies)
Discussion started by: niceboykunal123
7 Replies

7. Shell Programming and Scripting

How can I automate a script?

Hi All, Can I automate a script when some one trying to 'vi' (open) a file. For Example, I am having a file named 'SecuredShell.sh'. when a user types " vi SecuredShell.sh " in unix command prompt a script named secure.sh needs to be automated. Can this be possible. if Yes please guide... (2 Replies)
Discussion started by: little_wonder
2 Replies

8. Shell Programming and Scripting

mail script to automate

Hi, Here below the logs from the mail server: less /var/log/messages: Sep 6 04:03:31 server-59 out: 1252227811|webmaster@zilia.com|antonino.granata@gmail.com|2175|success|1 Sep 6 04:03:33 server-59 in: 1252227813|news@tarot.com|junk@thess.com|30376|success|1 Sep 6 04:03:35 server-59... (8 Replies)
Discussion started by: gsiva
8 Replies

9. Shell Programming and Scripting

Automate remote script

Hi all, I need to execute a script on a remote machine that are connected to the network.The basic requirement is to write a script which will login in remote machine and then execute the other script automatically placed in remote machine.So that I need to execute the remote machine script... (3 Replies)
Discussion started by: smartgupta
3 Replies

10. Windows & DOS: Issues & Discussions

automate the script

Dear all, I I want to login to my Linux machine using putty and then run some script from Windows machine.we can do it after loging it and then execute the script by typing it in putty command line screen. but I want to automate it.So whenever I will fire this script,it will do the following... (4 Replies)
Discussion started by: smartgupta
4 Replies
WebService::YouTube::Videos(3pm)			User Contributed Perl Documentation			  WebService::YouTube::Videos(3pm)

NAME
WebService::YouTube::Videos - Perl interface to youtube.videos.* VERSION
This document describes WebService::YouTube::Videos version 1.0.3 SYNOPSIS
use WebService::YouTube::Videos; my $api = WebService::YouTube::Videos->new( { dev_id => YOUR_DEV_ID } ); # Call API youtube.videos.list_featured my @videos = $api->list_featured; foreach my $video (@videos) { # $video->isa('WebService::YouTube::Video'); } # Call other APIs my @videos = $api->list_by_user($user); my @videos = $api->list_by_tag($tag); my $video = $api->get_details($video_id); # Parse XML my @video = $api->parse_xml($xml); # when $xml contains <video_list> my $video = $api->parse_xml($xml); # when $xml contains <video_details> DESCRIPTION
This is a Perl interface to YouTube REST API. See Developer APIs <http://youtube.com/dev> and Developer API -- REST Interface <http://youtube.com/dev_rest> for details. SUBROUTINES
/METHODS new(\%fields) Creates and returns a new WebService::YouTube::Videos object. %fields can contain parameters enumerated in "ACCESSORS" section. parse_xml($xml) Parses XML and returns the result. $xml should be an object that XML::Simple can understand. get_details( $video_id ) Returns a WebService::YouTube::Video object. $video_id is an ID of the video which you want to get details. See <http://youtube.com/dev_api_ref?m=youtube.videos.get_details> for details. list_by_tag( $tag, \%fields ) Returns an array of WebService::YouTube::Video object. $tag is a keyword string separated by a space. %fields can contain the optional parameters. page 1 <= page per_page per_page <= 100 (default 20) See <http://youtube.com/dev_api_ref?m=youtube.videos.list_by_tag> for details. list_by_user( $user ) Returns an array of WebService::YouTube::Video object. $tag is a keyword string separated by a space. %fields can contain optional parameters. See <http://youtube.com/dev_api_ref?m=youtube.videos.list_by_user> for details. list_featured( ) Returns an array of WebService::YouTube::Video object. See <http://youtube.com/dev_api_ref?m=youtube.videos.list_featured> for details. ACCESSORS dev_id Developer ID ua LWP::UserAgent object DIAGNOSTICS
dev_id is required Developer ID is required when you call API of YouTube. invalid XML The XML is not a YouTube's XML. unknown response The ut_response is neither <video_list> nor <video_details>. CONFIGURATION AND ENVIRONMENT
WebService::YouTube::Videos requires no configuration files or environment variables. DEPENDENCIES
Class::Accessor::Fast, LWP::UserAgent, XML::Simple, WebService::YouTube::Util, WebService::YouTube::Video INCOMPATIBILITIES
None reported. BUGS AND LIMITATIONS
No bugs have been reported. Please report any bugs or feature requests to "bug-webservice-youtube@rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-YouTube>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. AUTHOR
Hironori Yoshida <yoshida@cpan.org> LICENSE AND COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. perl v5.10.1 2010-08-01 WebService::YouTube::Videos(3pm)
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy