Displaying videos from Youtube in Coppermine. - Page 4 Displaying videos from Youtube in Coppermine. - Page 4
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Displaying videos from Youtube in Coppermine.

Started by Nibbler, October 31, 2006, 03:42:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nibbler

Attached is a modded version of upload.php that allows you to use the mod on servers without URL fopen support. You must however have cURL available instead.

Pascal YAP

Nibbler,

My host do not allow fopen;
I'll try in  few minutes your new upload.php... and i wish it's good news for my Funpic.org host  ;)

PYAP

carlo1

i used your upload.php and the theme.txt a few answers before. i changed .txt to .php and uploaded the 2 new files. no i go to upload new pics, after pressing the upload button i get this error:
Fatal error: Call to undefined function curl_init() in /srv/www/httpd/phost/h/de/pytalhost/xxx/web/cpg141/upload.php on line 37

my upload.php looks like this:
starting with line 36:
function file_get_contents_curl($url) {
   $ch = curl_init($url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $content = curl_exec($ch);
   curl_close($curl_handle);
   return $content;
}


i hope you can help me, i also need a hack for google video.

Nibbler

Quote from: Nibbler on January 03, 2007, 12:39:08 AM
You must however have cURL available instead.

You don't have cURL available, so you can't use it.

carlo1

what i must do now? i follow the instruction on site one, but i doesn´t work. can somewhen send me a correct upload.php so i must only chance the ID.

thank you.

carlo1

the upload.php works now but if i change the theme.php i get a new error.
i paste your code at the end of the side.
Template error
Failed to find block 'report_file_button'(#(<!-- BEGIN report_file_button -->)(.*?)(<!-- END report_file_button -->)#s) in :

you can see it here. http://hoelzlmani.pytalhost.de/cpg141/displayimage.php?album=200&pos=0

If i use the theme.txt from before, i can see the video but the site looks confused.

Nibbler

Make the change correctly and you won't get an error message...

flux

#67
hi,

i've tested this code on my invision1.3 bridged cpg and it seems something's going wrong at some point..

well "uploading" youtube videos works okay but the video info (keywords, description..) is not parsed and inserted in the final upload form

i've tried to follow the upload process and as far as i've understood how it works, i found out that the parsing code block is never processed because it won't enter the following test block :


    if(USER_UPLOAD_FORM == '0') {

        // The user should have the 'single upload only' form.


what should be the group upload conf in order to get an USER_UPLOAD_FORM set to 0 ?

that's probably just a detail but i'd like to fix it..
thx


####

I've fixed the problem and post my modifications here shortly

flux

okay so here are the modifications i made to my upload.php in order to get the youtube video data working :

those modifications won't break the original hack so you can/have to apply the original hack along with this if you want it fully operational

locate :

       
        if ($CONFIG['read_iptc_data']) {
   $iptc = get_IPTC($path_to_image);
        }


replace it with :


    if (preg_match('/^youtube_(.*)\.jpg$/', $file_set[0], $ytmatches)){

$iptc = array();

$vid = $ytmatches[1];

$xdata = file_get_contents("albums/edit/yt_".$vid.".xml");

// todo: parse the xml properly
preg_match('/<description>(.*)<\/description>/', $xdata, $xmatches);
$iptc['Caption'] = substr($xmatches[1], 0, $CONFIG['max_img_desc_length']);

// todo: parse the xml properly
preg_match('/<tags>(.*)<\/tags>/', $xdata, $xmatches);
$iptc['Keywords'] = explode(" ", $xmatches[1]);

// todo: parse the xml properly
preg_match('/<title>(.*)<\/title>/', $xdata, $xmatches);
$iptc['Title'] = substr($xmatches[1], 0, 255);     

} elseif ($CONFIG['read_iptc_data']) {
   $iptc = get_IPTC($path_to_image);
                }


- OPTIONAL -
Now if you want to fetch more data from youtube (duration, view count, youtube upload time, our update time) you can use the following code.
Unless you make your own modifications to other (theme) scripts that data won't be used at all !
I use the "user4" user picture data field to store that data. The user data field name does not need to be set, it can be left empty so it won't appear on the upload forms or in the picture info table.
Needless to say that if you "user4" field is in use it will mess things up.. Of course you can use any other userX data field if you know how to change that bit of code.. (replace all "user4"/"field4" you see by your "userX"/"fieldX" value)

Locate :

if(!empty($CONFIG['user_field4_name'])) {

there are two of them, you can replace both, but in my case the first one is never used.

Replace it with :

// youtube/video flag
if (preg_match('/^youtube_.*\.jpg$/', $file_set[0])){
// youtube video duration
preg_match('/<length_seconds>([0-9]*)<\/length_seconds>/', $xdata, $xmatches);
$yt_flag_data = $xmatches[1]."|";
// youtube view count
preg_match('/<view_count>([0-9]*)<\/view_count>/', $xdata, $xmatches);
$yt_flag_data .= $xmatches[1]."|";
// youtube upload time
preg_match('/<upload_time>([0-9]*)<\/upload_time>/', $xdata, $xmatches);
$yt_flag_data .= $xmatches[1]."|";
// our update time
$yt_flag_data .= time();

$form_array[] = array('user4', $yt_flag_data, 4);

} elseif(!empty($CONFIG['user_field4_name'])) {


the data is stored in the following format : duration_seconds|youtube_view_count|youtube_upload_time|cpg_update_time (ex: 54|95|1168283825|1168676023)


- BUGFIX -
okay there is one tiny bug in the original hack, it may have been discussed/fix elsewhere/before but i had to fix it in my script so..
The bug is the following : the xml file containing all the youtube data is not deleted after the video is added to the gallery.

Locate:

        // First, we delete the preview image.
        if ((!strstr($preview_path, 'thumb')) and (file_exists($preview_path))) {

            unlink($preview_path);


Insert BELOW:

// youtube xml data cleanup
if (preg_match('/^youtube_(.*)\.jpg$/', $file_set[0], $ytmatches)){
if (file_exists("albums/edit/yt_".$ytmatches[1].".xml")) {
unlink("albums/edit/yt_".$ytmatches[1].".xml");
}
}



- Known unfixed BUG -
Using the hack to test my modifications i also found another bug.
If you upload the same video twice, the upload process will succeed without errors (preview & thumbs ok) but the actual video won't work because cpg upload process will change the "picture" filename of the video in order not to overwrite the existing one and so it will also change the url of the video, pointing to a non existing video.

well that's about it
hope it helps..

Tai

Just like to add a thanks for this hack Nibbler.

It worked flawlessly and is a great addition to the site.

puku

Hi,
first I have to say well done this is realy great hack ... thanx
and now my question: can I allow Guests to upload YouTube "links" somehow ?? because this works great but the YouTube uploads fields are displayed only for registered users ...
thank you

Nibbler

Quote from: Nibbler on October 31, 2006, 03:42:27 AM


           // Youtube
           if (USER_ID) {
            $form_array[] = 'Youtube uploads';
              $form_array[] = array('', 'YT_array[]', 0, 256, 3);
              $form_array[] = 'Note: YouTube videos must be added in the form http://www.youtube.com/watch?v=xxxxxxxxxxx';
}


Change that section to set permissions. Remove the USER_ID check if you want to allow anyone to use it.

puku

Quote from: Nibbler on February 02, 2007, 08:10:29 PM
Change that section to set permissions. Remove the USER_ID check if you want to allow anyone to use it.

great, thank you  :)
great mod, great technical support  ;)

jape

Problems "browse upload"...
YouTube upload working very fine, but "normal browse uploads" not working...

i select "Upload" and browse my computer picture, and click "Continue"...

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fimg166.imageshack.us%2Fimg166%2F6245%2Fgallery1bd3.gif&hash=af1bc0e6dc1c500696e8db5abf1311682c2c91dd)

Now come problems.... look image...

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fimg250.imageshack.us%2Fimg250%2F1271%2Fgallery2hi0.gif&hash=3c47308d66abc34ee66c40dc2d9b1ead43556367)

And now i click "Continue" so image no uploads my gallerys...
Upload return back first towards...

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fimg176.imageshack.us%2Fimg176%2F4689%2Fgallery3df0.gif&hash=439d4f79eeeca4c3502c757cbfcc2da37068de33)

Thank you very much!  ;)

Supplement is my upload.php file....

thrower

I am very new to this stuff but have successfully put together a Joomla website with Coppermine integrated.  I have tried to implement this code for YouTube functionality but it is not working correctly.

I would really appreciate any advice here to get this to work.  To start with, I have added all of the code but when I go to the upload screen I do not see a separate section for Youtube videos.  I only have the file section and URI/URL section. 

Also, I'm not sure if I altered the right theme.php file.  I switched my configuration to use the classic theme and altered the theme.php file in the classic directory.

Thank you in advance for any help!

thrower

I have figured out quite a few things since my last post but I'm currently stumped.  Can someone please help with this problem? 

I can upload Youtube videos and I get an upload successful message after doing so.  When I select 'continue' to add the file information I get the following error box:  "The previous file could not be placed.  You have successfully placed all files." 

I can successfully upload files from the browse function and also from the URL/URI function.  I have two Coppermine installations that I have been trying this on.  The first one is just a straight Coppermine install.  I have gotten everything to work successfully for this one and it works great!  The second one is the CoppermineVis install that is integrated with Joomla, this is the actual one I plan to use for my site.  I should also mention that I have utilized the upload.php file posted above by Nibbler.  This functionality and the Coppermine software is great so far, I hope someone can help as it appears I am close.  Thanks!

vascodx

Great mod!!! No problem on installation. Thanks!!

ashelby

Quote from: h4nh4n on November 05, 2006, 02:10:44 PM
Hi Nibbler,
I am confused with theme.php which theme.php should we change, the ones we use for default template or only on /sample/theme.php ?


Thank you



Don't worry I solved the problem :) works like charming!

h4nh4n

It would be nice if you could add what you did.  Chances are someone else, LIKE ME. Has the same confusion.  :)  Which themes should we be changing, there are sever in the themes folder, should we change each one?  Or is their a global one somewhere?  Thanks.

Nibbler


ashelby

Thank you nibbler.  I figured it out last night and was going to post up here this morning.

It just needs be changed in the theme you are using, themes/clasic/theme.php in my case.

Now to change the CSS to match my site and then I'll post a link.

The YOUTUBE mod works GREAT by the way.  It may not be used to much for what I am making, but it is still really neat.  I had the dev account setup in about 2 minutes at youtube and all the coding to the theme.php done in about 5 minutes.

I use godaddy and they run php 4 by default, so I used the code you added for php 4 and it worked fine.  Then I saw godaddy.com will let you upgrade your account to run the php 5 through the control panel there.  Takes 24 hours to get changed, so I may need to go back and take out that php 4 code I added. 

Off to mod, thanks again!