Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get youtube video url form webpage source

Tags:

html

url

youtube

Is it possible to get the download URL of currently playing video from source of YouTube webpage?Thanks in advance.Please help me.

Actually I have a downloader but it is not working now.When I have tried with the URL provided by the downloader in browser it returns an error page says "Access to the webpage was denied".The Url that I got for a video is as " http://r14---sn-h557snel.c.youtube.com/videoplayback?gcr=in&ip=121.241.181.70&upn=OOcjKEO_S6I&cp=U0hUTFZQT19KU0NONF9OSlNGOmFRT2JSUUs2bDVi&ipbits=8&fexp=900148,920704,912806,928001,922403,922405,929901,913605,929104,913546,913556,908496,920201,913302,919009,911116,901451,902556&ms=au&mt=1357625350&mv=m&id=31a79fcdbfc6c2f6&sparams=cp,gcr,id,ip,ipbits,itag,ratebypass,source,upn,expire&expire=1357651559&itag=18&key=yt1&newshard=yes&source=youtube&ratebypass=yes&sver=3"

Few months before the format of URL was " http://o-o---preferred---sn-h557snes---v24---lscache3.c.youtube.com/videoplayback?upn=AmmxhSpq470&sparams=cp,gcr,id,ip,ipbits,itag,ratebypass,source,upn,expire&fexp=917013,906437,916626,922401,920704,912806,927201,925706,922403,913546,913556,916805,920201,901451&ms=au&expire=1353668177&itag=18&ipbits=8&gcr=in&sver=3&ratebypass=yes&mt=1353646087&ip=121.241.181.70&mv=m&source=youtube&key=yt1&cp=U0hUSFZRVl9MUUNONF9OS1pCOmhtUTVMak5oTVNy&id=c429fa5466ee9447&newshard=yes "

So I don't know whether the downloader gives the correct URL. Please help me

like image 288
user1767260 Avatar asked Dec 19 '25 23:12

user1767260


1 Answers

I have written a simple python code that can fetch youtube href from html code. hope it can help you:

#!/usr/bin/env python

import re

pattern = '.*<(iframe|param).*(src|value)="(?P<link>http://www.youtube.com/(embed|v)/[a-zA-Z0-9/\.\?&;=\+_-]+);?.*".*>.*</(iframe|param)>.*'

action = re.compile(pattern)
result = action.findall('<div><iframe.....></iframe><param......></param></div>')

print result 

https://gist.github.com/Mortezaipo/5707738

like image 160
mortymacs Avatar answered Dec 22 '25 15:12

mortymacs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!