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 12-19-2012, 04:26 PM   PM User | #571
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Youtube changed the way the video file URLs are displayed in the source code.

For those of you with the free version, do me a favor and test this new code out in the PHP converter class (this replaces the current SetFlvUrls method):

PHP Code:
        private function SetFlvUrls($file_contents)
        {
            
$vidUrls = array();
            
$vidSrcTypes $this->GetVidSrcTypes();
            if (
preg_match('/(yt\.playerConfig =)([^\r\n]+)/'$file_contents$matches) == 1)
            {
                
$jsonObj json_decode(trim($matches[2], ';'));
                if (isset(
$jsonObj->args->url_encoded_fmt_stream_map))
                {
                    
$urls urldecode(urldecode($jsonObj->args->url_encoded_fmt_stream_map));
                    
//die($urls);
                    
if (preg_match('/^((.+?)(=))/'$urls$matches) == 1)
                    {
                        
$urlsArr preg_split('/,'.preg_quote($matches[0], '/').'/'$urls, -1PREG_SPLIT_NO_EMPTY);
                        foreach (
$urlsArr as $url)
                        {
                            if (
$matches[0] != 'url=')
                            {
                                
$url = ($url != $urlsArr[0]) ? $matches[0].$url $url;
                                
$urlBase preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/'"$3$4"$url);
                                
$urlParams preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/'"$1$5"$url);
                                
$url $urlBase "&" $urlParams;
                            }
                            else
                            {
                                
$url preg_replace('/^(url=)/'""$url);
                            }
                            
$url preg_replace('/(.*)(itag=\d+&)(.*?)/''$1$3'$url1);
                            if (
preg_match('/quality=small/',$url) != 1)
                            {
                                
$url preg_replace('/sig=/'"signature="$url);
                                
$url trim($url',');
                                
$url .= '&title=' urlencode($this->ExtractSongTrackName($file_contents$vidSrcTypes[0]));
                                
$url preg_replace_callback('/(&type=)(.+?)(&)/', function($match){return $match[1].urlencode($match[2]).$match[3];}, $url);
                                
$vidUrls[] = $url;
                            }
                        }
                        
$vidUrls array_reverse($vidUrls);
                        
//die(print_r($vidUrls));
                    
}
                }
            }
            
$this->_flvUrls $vidUrls;
        } 
The same basic logic should be applicable to the paid-for version as well...but I have yet to work on the code for that version...don't worry, It's coming soon!

For now, please let me know if the above code works, and thanks again for your continued patience.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)

Last edited by chump2877; 12-19-2012 at 05:00 PM..
chump2877 is offline   Reply With Quote
Old 12-19-2012, 05:08 PM   PM User | #572
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
yup working
bbrog is offline   Reply With Quote
Old 12-19-2012, 06:32 PM   PM User | #573
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
The new (updated and hopefully stable) distribution of files is located at the bottom of this post.

Quote:
PLEASE SEE THIS POST FOR IMPORTANT INFO REGARDING THE USE AND INSTALLATION OF THIS SCRIPT.

DO NOT USE THE ZIP DISTRIBUTION LOCATED AT THE ABOVE LINKED PAGE. USE ONLY THE ZIP FILE ATTACHED TO THE BOTTOM OF THIS POST.
New in this release:

1) YouTube changed the format of video file URLs in the video page source code. This fix addresses this change.

I will soon be updating the paid-for version of the app as well, and I will email an updated (free) copy to all those who have already purchased the script. (Updates will be sent to your Tradebit email addresses only.)

As always, please let me know if you have any questions/concerns regarding the above and/or the code.
Attached Files
File Type: zip 12-19-12.zip (7.0 KB, 266 views)
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-19-2012, 08:30 PM   PM User | #574
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Hello everyone,

As promised, I have just finished updating the paid-for version of my software. New in this version:

1) YouTube changed the format of video file URLs in the video page source code. This fix addresses this change.

All previous customers who have purchased the paid-for version of my app are receiving this new, updated version via the e-mail addresses that you provided at Tradebit.com.

Please report any issues with either the paid-for version or the free version in this forum thread.

Thanks!
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-19-2012, 08:42 PM   PM User | #575
belveder
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
belveder is an unknown quantity at this point
I have paid version of your script. Can you tell me what exactly should I change because I have custom design and some custom code in those files?

Thanks.
belveder is offline   Reply With Quote
Old 12-19-2012, 09:02 PM   PM User | #576
soofi
New to the CF scene

 
Join Date: Jul 2012
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
soofi is an unknown quantity at this point
Quote:
Originally Posted by chump2877 View Post
Hello everyone,

As promised, I have just finished updating the paid-for version of my software. New in this version:

1) YouTube changed the format of video file URLs in the video page source code. This fix addresses this change.

All previous customers who have purchased the paid-for version of my app are receiving this new, updated version via the e-mail addresses that you provided at Tradebit.com.

Please report any issues with either the paid-for version or the free version in this forum thread.

Thanks!

Hello Randall,

I have paid version of your script as well. Can you please tell us what exact code needs to be changed because I have custom designed site and I dont want to mess up everything..

kind regards.

Jay

Thanks.
soofi is offline   Reply With Quote
Old 12-19-2012, 11:14 PM   PM User | #577
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
To those of you that may have "customized" the code in the PHP converter class (regardless of which version of my code you're using):

The point of putting all of the functionality related to video conversion into a PHP class is to take advantage of one of the fundamental advantages of an object-oriented programming (OOP) design: code abstraction. So you put all of your fundamental logic in a "base" PHP class, and then any customization of those classes can be achieved in inherited classes (via overriding class members). Subsequently, the base class doesn't need to be edited.

In the context of my code, the base PHP class is YouTubeToMp3Converter.class.php or VideoConverter.class.php (depending on what version you have). In relation to the recent fix, if you need to customize this class, you can extend it with your own class that overrides the SetFlvUrls() or SetVidSourceUrls() methods (again, depending on what version you have). And you don't have to edit the base class.

The moral of the story here is that you can customize my code without editing the core class code. And if you edit the core class code, then you make it harder for yourself to embrace newer versions of the software.

Regarding the recent fix, the only code that changes is in the SetFlvUrls() or SetVidSourceUrls() methods. The sole purpose of these methods is to retrieve an array of video URLs that can be used for conversion. So forgive me if I am having a hard time understanding why you would want to "customize" that functionality? And if you did need to customize something there, please don't change the code directly in the conversion class. Extend the class with your own class and make your changes in your custom class.

All of this taken into consideration, if you need any further help (from me) applying the fix to your custom/modified code, then I will have to charge you for the work and time spent.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-20-2012, 05:23 AM   PM User | #578
Luckyplaya
New Coder

 
Join Date: Sep 2012
Location: Germany
Posts: 32
Thanks: 8
Thanked 1 Time in 1 Post
Luckyplaya is an unknown quantity at this point
Which files need to be changed in the paid version?
Luckyplaya is offline   Reply With Quote
Old 12-20-2012, 07:23 AM   PM User | #579
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by Luckyplaya View Post
Which files need to be changed in the paid version?
Quote:
the base PHP class is YouTubeToMp3Converter.class.php or VideoConverter.class.php
Quote:
the only code that changes is in the SetFlvUrls() or SetVidSourceUrls() methods
SetVidSourceUrls() method in VideoConverter.class.php. That is the only code to change in paid-for version.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
Luckyplaya (12-28-2012)
Old 12-20-2012, 07:33 PM   PM User | #580
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by OujdaCoder View Post
hi bro i need VideoConverter.class.php update Please
Please send me your Tradebit.com email address -- the one you supplied when purchasing my software. Then I will send you the update. FYI - You should have already been emailed this update.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-20-2012, 07:53 PM   PM User | #581
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by OujdaCoder View Post
can You Give Me The Link Of Product and How a can Pay
http://www.codingforums.com/showpost...&postcount=321

Payment by PayPal or credit card via Tradebit.com
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-20-2012, 09:58 PM   PM User | #582
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by OujdaCoder View Post
a Payed Bro send Me the Update File at
elodie.verborg@hotmail.fr
You purchased the software, so you now have the most updated version.

Quote:
bro all can You add Xvideos and tube8 and xhamster
This may be a mistake on my part, but I'm going to assume that this is a serious question. You can add additional video hosting sites to the software with a little customization of the code.

If the mentioned sites have APIs for accessing their video content, then that would be ideal. Otherwise, you may have to scrape the HTML source code of their pages to retrieve video file URLs.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-24-2012, 07:18 AM   PM User | #583
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
Hey, been having trouble downloading videos again is it just my side or did youtube change stuff up again?
bbrog is offline   Reply With Quote
Old 12-24-2012, 07:57 AM   PM User | #584
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by bbrog View Post
Hey, been having trouble downloading videos again is it just my side or did youtube change stuff up again?
Still working for me...Can you provide URLs of specific videos?
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 12-24-2012, 08:36 AM   PM User | #585
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
Hi, been mostly getting problems with http://www.youtube.com/watch?v=MNvvzOpgOdo from this artist and this song.
bbrog is offline   Reply With Quote
Reply

Bookmarks

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

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 06:23 PM.


Advertisement
Log in to turn off these ads.