![]() |
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 |
do you mean "uAFjgpuWREM" from https://youtube.com/watch?v=uAFjg...6cFAAAAAAAAAAA or what?
|
ya exactly
perl Code:
perl -e '$_=shift; print(/v=(.+)/);' https://youtube.com/watch?v=8tRUckf0WbY Code:
echo https://youtube.com/watch?v=4bQOSRm9YiQ | awk -F 'v=' '{print $2}' Code:
echo https://youtube.com/watch?v=sGgOM1UsqtE | sed 's/.*watch?v=\([^&]*\).*/\1/' |
No php?
Code:
php -r 'echo next(explode( "v=", $argv[1] ) );' https://youtube.com/watch?v=8tRUckf0WbY Code:
php -r 'echo preg_replace ( "/.*v\=([a-z0-9]+).*/i", "$1", $argv[1] );' https://youtube.com/watch?v=8tRUckf0WbY |
here's a ruby sample:
Code:
echo 'https://youtube.com/watch?v=8tRUckf0WbY' | ruby -ne 'puts $1 if /v=(\w+)/' |
thanks just need a python one now ;)
|
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 |
spanks ;)
|
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=}" |
zsh ;)
Code:
s='https://youtube.com/watch?v=k6R9hMV1jNk'; a=("${(s/v=/)s}"); echo $a[2] |
Qbasic???
|
|
Quote:
|
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