10-05-2008
Perl Script to Extract the Name of the Video out of a Youtube URL
First of all thanks for your help. I made this script out of the need to extract the youtube video name from a youtube address. I hope it helps.
Warmest regards,
Tony Mty
#!/usr/bin/perl
# s.u.f.y.a.
# Strip the Url From a Youtube Address
# Purpose: This small perl snippet will extract the name of the video out
# from a youtube address.
# Based on:
#
https://www.unix.com/newreply.php?do=...=1&p=302231091
# hth
# tony mty
#
print "\Script to strip the url from a youtube address";
print "\nYoutube URL: ";
$youtubesurl = <STDIN>;
$youtubesurl=~ s/^\s+//; #strips off space
$youtubesurl=~s/.*watch\?v=//; #returns everthing after "watch?="
$youtubesurl=~s/&.*//; #returns everthing before "$"
print "$youtubesurl\n";
print "Done.\n";
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a string as follows
IS*blahblah
TED~blahblah
etc.
I want to list down only IS and TED
Can someone help me? (24 Replies)
Discussion started by: kumariak
24 Replies
2. Shell Programming and Scripting
Hi,
I'm currently working on a project that requires parsing xml file. One of the field in the xml is shown below (don't remember exactly):
<variable="ITEM">12345678</variable>
I coded my script keeping in mind that the value denoted in bold will always be a number. After getting just the... (1 Reply)
Discussion started by: mradul_kaushik
1 Replies
3. UNIX for Dummies Questions & Answers
HI,
I have a directory structure. /abc/def/ghi/
I want to store it into array.
So that if I do a pop function on that array I can easily go to previous directory.
But how can i split and store it.
@Directory = split(/\//,$DirectoryVarialbe)
That doest works. Any other escape sequence... (5 Replies)
Discussion started by: deepakwins
5 Replies
4. Shell Programming and Scripting
Hi , I use the following simple perl script to find the yesterday time
perl -e ' use POSIX(strftime); print POSIX::strftime("%a %b %e %H:%M:%S %Y", localtime(time-86400*$ARGV))' 1
However in the perl version 4 , it gives me the following error :
Do the perl version 4 does not support... (4 Replies)
Discussion started by: youareapkman
4 Replies
5. UNIX for Advanced & Expert Users
Hi
just for regular use i m working on small module written in perl for getting date in specified format like i have to specify date format and then seperator to seperate date i am 95% done. now i m sure explanation i gave is not good enough so i am putting output here :
C:\Documents and... (2 Replies)
Discussion started by: zedex
2 Replies
6. Shell Programming and Scripting
All I'm trying to split a string at the $ into arrays
@data:=<dataFile>
a $3.33
b $4.44
dfg $0.56
The split command I have been playing with is:
split(/\$/, @data)
which results with
a .33 b .44 dfg .56
any help with this is appreciated
/r
Rick (9 Replies)
Discussion started by: schultz2146
9 Replies
7. Shell Programming and Scripting
Hello,
I have a problem when i execute the script underneath.
If i tape azerty 123 and i use the arrow touch, in the file /tmp/test i have the caracter #!/usr/bin/ksh
clear
echo "Taper l adresse IP de la partition a creer :"
tput cup 1 48
read Adress
echo $Adress
echo "${Adress}" >>... (0 Replies)
Discussion started by: khalidou13
0 Replies
8. Shell Programming and Scripting
Hello
I have string (string can have more sections)
LINE="AA;BB;CC;DD;EE"I would like to assigne each part of string separated by ";" to some new variable.
Can someone help? (4 Replies)
Discussion started by: vikus
4 Replies
9. Shell Programming and Scripting
Hello Gurus,
I have a script developed...
#!/bin/bash
#---------------------------------------------------------------------
# This pScript will remove/replace the special characters fromfiles
#---------------------------------------------------------------------
trxdate="`date... (1 Reply)
Discussion started by: nanduedi
1 Replies
10. Shell Programming and Scripting
when I execute the unix commands its works normally in the 1st part.
When I the tried the same in shell scripting the directory is not displayed in 2nd part example. please let me know what needs to be done.
Unix :
client=~zsvdbs
echo $client
/shome/zsvhome/zsvdbs
Using... (3 Replies)
Discussion started by: keerthi2016
3 Replies
LEARN ABOUT DEBIAN
webservice::youtube::videos
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)