GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   python and ruby folk in here (https://gfy.com/showthread.php?t=1060722)

fris 03-11-2012 10:21 AM

python and ruby folk in here
 
im putting together a collection of youtube one liners.

anyone wanna submit one that works from console to get a youtube video id out of a youtube url?

;)

:thumbsup

extreme 03-11-2012 11:00 AM

do you mean "uAFjgpuWREM" from https://youtube.com/watch?v=uAFjg...6cFAAAAAAAAAAA or what?

fris 03-11-2012 11:04 AM

ya exactly

perl

Code:

perl -e '$_=shift; print(/v=(.+)/);' https://youtube.com/watch?v=8tRUckf0WbY
awk

Code:

echo https://youtube.com/watch?v=4bQOSRm9YiQ | awk -F 'v=' '{print $2}'
sed

Code:

echo https://youtube.com/watch?v=sGgOM1UsqtE | sed 's/.*watch?v=\([^&]*\).*/\1/'
echo https://youtube.com/watch?v=sGgOM1UsqtE | grep -o 'watch\?v=[^&"]+' | sed -e 's#^[^=]*=##'
echo https://youtube.com/watch?v=sGgOM1UsqtE | sed -ne 's#^.*watch?v=\([^&"]*\+\).*$#\1#p'
echo https://youtube.com/watch?v=sGgOM1UsqtE | sed '/watch?v=/! d;s/.*v=//;s/\(.\{11\}\).*/\1/'


Brujah 03-11-2012 03:04 PM

No php?

Code:

php -r 'echo next(explode( "v=", $argv[1] ) );' https://youtube.com/watch?v=8tRUckf0WbY
or

Code:

php -r 'echo preg_replace ( "/.*v\=([a-z0-9]+).*/i", "$1", $argv[1] );' https://youtube.com/watch?v=8tRUckf0WbY

Brujah 03-11-2012 03:21 PM

here's a ruby sample:

Code:

echo 'https://youtube.com/watch?v=8tRUckf0WbY' | ruby -ne 'puts $1 if /v=(\w+)/'

fris 03-11-2012 04:19 PM

thanks just need a python one now ;)

Brujah 03-11-2012 11:28 PM

I don't normally use python, but since no one else is bothering...

Code:

python -c "import re,sys; m = re.split('v=',sys.argv[1]); print m[1];" https://youtube.com/watch?v=8tRUckf0WbY

fris 03-12-2012 05:59 AM

spanks ;)

fris 03-12-2012 06:56 AM

here is some bash ;)

Code:

echo https://youtube.com/watch?v=sGgOM1UsqtE | grep -E 'v=[A-Za-z0-9_-]' | cut -d "=" -f 2
Code:

var='https://youtube.com/watch?v=sGgOM1UsqtE'; echo "${var#*v=}"
Code:

var='https://youtube.com/watch?v=sGgOM1UsqtE'; echo "${var##*[?&]v=}"
;)

fris 03-12-2012 09:39 AM

zsh ;)

Code:

s='https://youtube.com/watch?v=k6R9hMV1jNk'; a=("${(s/v=/)s}"); echo $a[2]

Emil 03-12-2012 10:06 AM

Qbasic???

Brujah 03-12-2012 04:37 PM

here is some human
https://youtube.com/watch?v=k6R9hMV1jNk

Code:

k6R9hMV1jNk

fris 03-13-2012 08:08 AM

Quote:

Originally Posted by Brujah (Post 18818747)
here is some human
https://youtube.com/watch?v=k6R9hMV1jNk

Code:

k6R9hMV1jNk

human heh ;)


All times are GMT -7. The time now is 09:19 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc