Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-26-2011, 08:35 AM   PM User | #61
expertmac
New Coder

 
Join Date: Mar 2011
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
expertmac is an unknown quantity at this point
Thumbs up

yes after Php.ini update its working fine & also its working faster.

thanks for you help.
expertmac is offline   Reply With Quote
Old 08-04-2011, 12:49 AM   PM User | #62
mathieu67
New Coder

 
Join Date: Feb 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mathieu67 is an unknown quantity at this point
I'm using your script "YoutubeToMp3Converter.class.php" Everything was working fine yesterday from the same server but today I woke and tested the script and now getting this error:

Error downloading video, Please check your URL.!

Can you think of anything? did youtube changed their video URL code again?

My site convert youtube to mp3

Thanks for your help.
mathieu67 is offline   Reply With Quote
Old 08-04-2011, 12:50 AM   PM User | #63
mathieu67
New Coder

 
Join Date: Feb 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mathieu67 is an unknown quantity at this point
@expertmac,

What did you do to fix it? I'm having the same issue as you.
mathieu67 is offline   Reply With Quote
Old 08-04-2011, 01:52 AM   PM User | #64
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by mathieu67 View Post
I'm using your script "YoutubeToMp3Converter.class.php" Everything was working fine yesterday from the same server but today I woke and tested the script and now getting this error:

Error downloading video, Please check your URL.!

Can you think of anything? did youtube changed their video URL code again?

My site convert youtube to mp3

Thanks for your help.
I'm getting the same error...I'll look into it and post a fix when I find one...
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 08-04-2011, 02:53 AM   PM User | #65
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
It does appear that YouTube has changed the format of FLV URLs in the source code...

Unfortunately, I don't have any more time right now to investigate this...I'll dabble with developing a fix in my spare time...

In the meantime, anyone is welcome to provide the regex or series of regular expressions required to parse and grab the FLV video URL from YouTube's source code...

To be continued...
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 08-04-2011, 03:39 AM   PM User | #66
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
As I was typing my last post, I realized what the problem was...

Here is the fix (pending further testing?):

The SetFlvUrl() method has been revised as follows:

PHP Code:
        private function SetFlvUrl($file_contents)
        {
            
$vidUrl '';
            if (
eregi('url_encoded_fmt_stream_map',$file_contents))
            {
                
$vidUrl end(explode('url_encoded_fmt_stream_map=',$file_contents));
                
$vidUrl urldecode(urldecode(current(explode('&',$vidUrl))));
                
$vidUrl current(explode(';',$vidUrl));
                
$vidUrl urldecode(end(explode('url=',$vidUrl)));
            }
            
$this->_flvUrl $vidUrl;
        } 
Download the revised YouTubeToMp3Converter.class.php below! ...And please let me know if you experience any issues with the code....
Attached Files
File Type: zip 8-3-11.zip (2.9 KB, 416 views)
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]

Last edited by chump2877; 08-04-2011 at 03:55 AM..
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
Laugh (08-04-2011)
Old 08-04-2011, 09:50 AM   PM User | #67
supercwis
New to the CF scene

 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
supercwis is an unknown quantity at this point
Quote:
Originally Posted by chump2877 View Post
As I was typing my last post, I realized what the problem was...

Here is the fix (pending further testing?):

The SetFlvUrl() method has been revised as follows:

PHP Code:
        private function SetFlvUrl($file_contents)
        {
            
$vidUrl '';
            if (
eregi('url_encoded_fmt_stream_map',$file_contents))
            {
                
$vidUrl end(explode('url_encoded_fmt_stream_map=',$file_contents));
                
$vidUrl urldecode(urldecode(current(explode('&',$vidUrl))));
                
$vidUrl current(explode(';',$vidUrl));
                
$vidUrl urldecode(end(explode('url=',$vidUrl)));
            }
            
$this->_flvUrl $vidUrl;
        } 
Download the revised YouTubeToMp3Converter.class.php below! ...And please let me know if you experience any issues with the code....
Hello,
Don't work any more
supercwis is offline   Reply With Quote
Old 08-04-2011, 10:40 AM   PM User | #68
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by supercwis View Post
Hello,
Don't work any more
What is the YouTube video page URL that you are using? I may have to tinker with the regular expressions some more so that they work on all YouTube URLs?

FWIW, I haven't had any problems yet...
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 08-04-2011, 11:11 AM   PM User | #69
supercwis
New to the CF scene

 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
supercwis is an unknown quantity at this point
Here is an example :
http://www.youtube.com/watch?v=2ZCUt...eature=r_and_b

i use firefox.
supercwis is offline   Reply With Quote
Old 08-04-2011, 12:57 PM   PM User | #70
Laugh
New to the CF scene

 
Join Date: Aug 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Laugh is an unknown quantity at this point
Hey Chump I'm registering JUST to say thank you! You saved me man! Thank you so much.

But one question, could you show us how to do this ourselves just incase youtube updates again?
Laugh is offline   Reply With Quote
Old 08-04-2011, 03:15 PM   PM User | #71
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by supercwis View Post
Here is an example :
http://www.youtube.com/watch?v=2ZCUt...eature=r_and_b

i use firefox.
I just tried "http://www.youtube.com/watch?v=2ZCUtnuAXg8" and it works fine for me...I'm not sure if anything other than "v" in the query string would cause the app to fail, but like the app front end says:

Quote:
Enter a valid YouTube.com video URL:
(i.e., "http://www.youtube.com/watch?v=HMpmI2F2cMs")
If other types of YouTube URLs dont work for you, then you'll need to write your own code to handle those URLs, or write some code to validate URLs so that they conform to the example URL format. (I didn't really program any validation because I'm just using this app recreationally, for my own personal use.)

Hope that helps....Good luck!
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 08-04-2011, 03:42 PM   PM User | #72
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by Laugh View Post
Hey Chump I'm registering JUST to say thank you! You saved me man! Thank you so much.

But one question, could you show us how to do this ourselves just incase youtube updates again?
Unfortunately, I can't really give you a magic formula for how to tweak the regex when YouTube updates their site...It's mostly just "educated" guessing and a vague familiarity with how YouTube stores and encodes video data in their source code.

What I can say is that, this time, video data is found in this part of the source code (of any given video page):

(Extracted from source at http://www.youtube.com/watch?v=hWGUnrIiOoI)

Code:
<embed type="application/x-shockwave-flash"     src="http://s.ytimg.com/yt/swfbin/watch_as3-vfl3rocf3.swf"     width="640" id="movie_player" height="363"    flashvars="fexp=900081&amp;enablecsi=1&amp;watermark=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Flogo-vfl_bP6ud.swf%2Chttp%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Fhdlogo-vfloR6wva.swf&amp;timestamp=1312468085&amp;allow_embed=1&amp;rvs=view_count%3D9133%26author%3DWinkSound%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DGEF12tbkwsw%26title%3DPro%2BTools%253A%2BCreating%2Ba%2BGlitch%2BEffect%2Bwith%2BElastic%2BAudio%26length_seconds%3D212%26featured%3D1%26thumbnailUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252FGEF12tbkwsw%252Fdefault.jpg%26id%3DGEF12tbkwsw%2Cview_count%3D604604%26author%3DIndoleMugen%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DnfwD05XA2YQ%26title%3DAutechre%2B-%2BGantz%2BGraf%26length_seconds%3D236%26thumbnailUrl%3Dhttp%253A%252F%252Fi3.ytimg.com%252Fvi%252FnfwD05XA2YQ%252Fdefault.jpg%26id%3DnfwD05XA2YQ%2Cview_count%3D311362%26author%3Dcrawler23%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DFLK70Ipe-tI%26title%3DAutechre%2B-%2BClipper%26length_seconds%3D474%26thumbnailUrl%3Dhttp%253A%252F%252Fi3.ytimg.com%252Fvi%252FFLK70Ipe-tI%252Fdefault.jpg%26id%3DFLK70Ipe-tI%2Cview_count%3D208837%26author%3Dchangoelectrico%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DQPEcjQXIHX0%26title%3DAutechre%2B-%2BBasscadet%26length_seconds%3D280%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FQPEcjQXIHX0%252Fdefault.jpg%26id%3DQPEcjQXIHX0%2Cview_count%3D1528748%26author%3Dnonameno5%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DdQEmaj9C6ko%26title%3DBoards%2Bof%2BCanada%2B-%2BEverything%2BYou%2BDo%2Bis%2Ba%2BBalloon%26length_seconds%3D421%26thumbnailUrl%3Dhttp%253A%252F%252Fi1.ytimg.com%252Fvi%252FdQEmaj9C6ko%252Fdefault.jpg%26id%3DdQEmaj9C6ko%2Cview_count%3D190273%26author%3DChubeMania%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DQLXzSefzVWU%26title%3DAutechre%2B-%2B444%26length_seconds%3D538%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FQLXzSefzVWU%252Fdefault.jpg%26id%3DQLXzSefzVWU%2Cview_count%3D12698859%26author%3Doptionalinfo%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DEjAoBKagWQA%26title%3DAll%2Bis%2Bfull%2Bof%2Blove%26length_seconds%3D249%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FEjAoBKagWQA%252Fdefault.jpg%26id%3DEjAoBKagWQA%2Cview_count%3D3062%26author%3DMrNightmare92%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DKFuIB9hsI1s%26title%3DAutechre%2B-%2BRotar%26length_seconds%3D485%26thumbnailUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252FKFuIB9hsI1s%252Fdefault.jpg%26id%3DKFuIB9hsI1s%2Cview_count%3D85572%26author%3DXyrofen%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D7nXcLBXR70M%26title%3DAutechre-%2Bsee%2Bon%2Bsee%26length_seconds%3D262%26thumbnailUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252F7nXcLBXR70M%252Fdefault.jpg%26id%3D7nXcLBXR70M&amp;vq=auto&amp;showpopout=1&amp;hl=en_US&amp;autohide=3&amp;url_encoded_fmt_stream_map=url%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v24.lscache5.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Cratebypass%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526itag%253D43%2526ip%253D0.0.0.0%2526signature%253D2DF581FE56F207F9B0CAA10EBBC5BF6C7E4B3EEB.47DFB1991F462266CD66DEDE6439D32969D10DA1%2526sver%253D3%2526ratebypass%253Dyes%2526expire%253D1312491600%2526key%253Dyt1%2526ipbits%253D0%2526id%253D8561949eb2223a82%26quality%3Dmedium%26fallback_host%3Dtc.v24.cache5.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D43%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v11.lscache3.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Calgorithm%25252Cburst%25252Cfactor%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526algorithm%253Dthrottle-factor%2526itag%253D34%2526ip%253D0.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253DA34A8A17D276340ED85A110313E2FEF15EE38B0F.C873EE99BF3B2667F3F819FA90420E9900D8CA69%2526expire%253D1312491600%2526key%253Dyt1%2526ipbits%253D0%2526factor%253D1.25%2526id%253D8561949eb2223a82%26quality%3Dmedium%26fallback_host%3Dtc.v11.cache3.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D34%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v2.lscache7.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Cratebypass%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526itag%253D18%2526ip%253D0.0.0.0%2526signature%253D789913C8B56F2644997E5D8CC761D3B862770A68.6A8AC65B5E2D7F2E269E82A422601441AB2B33D9%2526sver%253D3%2526ratebypass%253Dyes%2526expire%253D1312491600%2526key%253Dyt1%2526ipbits%253D0%2526id%253D8561949eb2223a82%26quality%3Dmedium%26fallback_host%3Dtc.v2.cache7.c.youtube.com%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26itag%3D18%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v9.lscache6.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Calgorithm%25252Cburst%25252Cfactor%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526algorithm%253Dthrottle-factor%2526itag%253D5%2526ip%253D0.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253D0AB728A9D6A142C109D06CEA277C6C523F2D6FB5.86BBF1C4078758244707B1B65C0E26F4B6A03F7B%2526expire%253D1312491600%2526key%253Dyt1%2526ipbits%253D0%2526factor%253D1.25%2526id%253D8561949eb2223a82%26quality%3Dsmall%26fallback_host%3Dtc.v9.cache6.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D5&amp;csi_page_type=watch&amp;keywords=Autechre%2Celectronica%2Cdropp%2Cwarp%2Caphex%2Cep7%2Cidm%2Cmusic%2Cvideo&amp;cr=US&amp;no_get_video_log=1&amp;endscreen_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fendscreen-vfl6JSdY7.swf&amp;fmt_list=43%2F640x360%2F99%2F0%2F0%2C34%2F640x360%2F9%2F0%2F115%2C18%2F640x360%2F9%2F0%2F115%2C5%2F320x240%2F7%2F0%2F0&amp;referrer=None&amp;video_id=hWGUnrIiOoI&amp;length_seconds=195&amp;enablejsapi=1&amp;sk=gb-MJ0HISRAnJxp-4dgRnf_1oE6YdH8bC&amp;theme=dark&amp;t=vjVQa1PpcFP7QuLQ4LWFlW0XZNVbeU4UAKSWcbwwkMs%3D&amp;plid=AASprsoGU23a2Fa8&amp;tmi=1"     allowscriptaccess="always" allowfullscreen="true" bgcolor="#000000">
The code in red is the URL-encoded FLV file location (I think I highlighted the right code -- it's hard to tell when it's encoded like that -- but that is the general vicinity in the source code)...It's just a matter of picking out the correct URL from that garbled mess and then URL-decoding it...

Also, as an aside, the series of regular expressions that I used in SetFlvUrl() could probably be made more efficient (from a coding perspective), but:

1) I wrote the code quickly, and
2) The code does what I need it to do, so I guess I don't care

As always, if something (namely, the regex) doesn't work, let me know and I'll try to fix it....But as long as it works, no matter how ugly it might look, I'm good with it
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]

Last edited by chump2877; 08-04-2011 at 03:45 PM..
chump2877 is offline   Reply With Quote
Old 08-04-2011, 06:11 PM   PM User | #73
mathieu67
New Coder

 
Join Date: Feb 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mathieu67 is an unknown quantity at this point
@chump2877,

I made the changes but now i'm getting this error:

Error generating MP3 file!

Anyone else? I think youtube is still making changes.


my site: Youtube Mp3 Converter
mathieu67 is offline   Reply With Quote
Old 08-04-2011, 06:46 PM   PM User | #74
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,547
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by mathieu67 View Post
@chump2877,

I made the changes but now i'm getting this error:

Error generating MP3 file!

Anyone else? I think youtube is still making changes.


my site: Youtube Mp3 Converter
what is the URL of the YouTube video page?
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 08-04-2011, 10:13 PM   PM User | #75
mathieu67
New Coder

 
Join Date: Feb 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mathieu67 is an unknown quantity at this point
Quote:
Originally Posted by chump2877 View Post
what is the URL of the YouTube video page?
I tried several but here's one that is not working that worked 2 days ago.

http://www.youtube.com/watch?v=o8Y9-JlSRXw


my site: http://www.convert-youtube-to-mp3.com
mathieu67 is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, class, conversion, dailymotion, ffmpeg, free youtube mp3 script, free youtube script, mp3, php, script, video, youtube, youtube to mp3, youtube to mp3 php script, youtube to mp3 script

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:24 AM.


Advertisement
Log in to turn off these ads.