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

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

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 2 Guests are viewing this topic.

afrohead


Nibbler


afrohead

Evidently you can't get an API ID anymore, or at least there isn't any way of applying for one from the YouTube API pages I have visited.  If I understand what you are saying if we want to use this mod we need a developer API ID?  That is a real bummer as it appears you no longer can get an API ID for YouTube.  Looks like a fun mod though.

afrohead

Yes, you still can get a developer api id from YouTube.  I had to Google it to find the right information to get a developer id as they don't have any good information on the YouTube/dev site.  How ironic.  You have to have a YouTube account of course, then you can visit this page to get your ID: http://www.youtube.com/my_profile_dev

Hope that helps.  Thanks

afrohead

This mod works great with CPMfetch and the ITunes Flash Slideshow by RPHMedia.  Nibbler you wrote one nice mod here and I just want to say thanks.  Both the CPMFetch and ITunes slideshow mods pick up the thumbnail image off of the gallery photos.  This mod creates thumbnails for each YouTube video and they display perfectly in the aforementioned syndication mods.

jeffnow

Hello, I got the mod installed, youtube work great, but now my movie files (wma) no longer play. Please, tell me why? Thanks


Keanu

Okay ya'll going to hate me for this one... Can you help me out with my code? :D...

I'm so close to finishing it, I just need to do "theme.php"...


<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.3
  $Source: /cvsroot/coppermine/stable/themes/digital_red/theme.php,v $
  $Revision: 2.0 $
  $Author: DaMysterious $
  $Date: 2006-01-12 10:01:00 $
**********************************************/

//define('THEME_IS_XHTML10_TRANSITIONAL',1);

// HTML template for main menu
$template_sys_menu = <<<EOT
                <span class="topmenu">

<!-- BEGIN my_gallery -->
                        <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}">{MY_GAL_LNK}</a><br /><br />
<!-- END my_gallery -->

<!-- BEGIN allow_memberlist -->
                        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}">{MEMBERLIST_LNK}</a><br /><br />
<!-- END allow_memberlist -->

<!-- BEGIN my_profile -->
                        <a href="{MY_PROF_TGT}">{MY_PROF_LNK}</a><br /><br />
<!-- END my_profile -->

<!-- BEGIN faq -->
                        <a href="{FAQ_TGT}" title="{FAQ_TITLE}">{FAQ_LNK}</a><br /><br />
<!-- END faq -->

<!-- BEGIN enter_admin_mode -->
                        <a href="{ADM_MODE_TGT}" title="{ADM_MODE_TITLE}">{ADM_MODE_LNK}</a><br /><br />
<!-- END enter_admin_mode -->

<!-- BEGIN leave_admin_mode -->
                        <a href="{USR_MODE_TGT}" title="{USR_MODE_TITLE}">{USR_MODE_LNK}</a><br /><br />
<!-- END leave_admin_mode -->

<!-- BEGIN upload_pic -->
                        <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}">{UPL_PIC_LNK}</a><br /><br />
<!-- END upload_pic -->

<!-- BEGIN register -->
                        <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}">{REGISTER_LNK}</a><br /><br />
<!-- END register -->

<!-- BEGIN login -->
                        <a href="{LOGIN_TGT}" title="">{LOGIN_LNK}</a>
<!-- END login -->

<!-- BEGIN logout -->
                        <a href="{LOGOUT_TGT}" title="">{LOGOUT_LNK}</a><br />
<!-- END logout -->
</span>
EOT;

// HTML template for sub_menu
$template_sub_menu = <<<EOT

<!-- BEGIN custom_link -->
     <a href="{CUSTOM_LNK_TGT}" title="{CUSTOM_LNK_TITLE}">{CUSTOM_LNK_LNK}</a><br /><br />
<!-- END custom_link -->

<!-- BEGIN album_list -->
     <a href="{ALB_LIST_TGT}" title="{ALB_LIST_TITLE}">{ALB_LIST_LNK}</a><br /><br />
<!-- END album_list -->
<a href="{LASTUP_TGT}">{LASTUP_LNK}</a><br /><br />
<a href="{LASTCOM_TGT}">{LASTCOM_LNK}</a><br /><br />
<a href="{TOPN_TGT}">{TOPN_LNK}</a><br /><br />
<a href="{TOPRATED_TGT}">{TOPRATED_LNK}</a><br /><br />
<a href="{FAV_TGT}">{FAV_LNK}</a><br /><br />
<a href="{SEARCH_TGT}">{SEARCH_LNK}</a>

EOT;


?>



Okay, as you may be able to see..? There is no;

if (isset($image_size['reduced'])) {

So I have no way to add the other part on.. Now I was reading around that.. Well - From the impression given, that you could just over-write the old theme.php with a theme.php that actually has the previously coded in it.

But, when I tried that.. It phailed badly... Now all thats showing on my site is:


// Displays a picture function theme_html_picture() { global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER; global $album, $comment_date_fmt, $template_display_media; global $lang_display_image_php, $lang_picinfo; $pid = $CURRENT_PIC_DATA['pid']; $pic_title = ''; if (!isset($USER['liv']) || !is_array($USER['liv'])) { $USER['liv'] = array(); } // Add 1 to hit counter if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) { add_hit($pid); if (count($USER['liv']) > 4) array_shift($USER['liv']); array_push($USER['liv'], $pid); } if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored $condition = true; }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){ $condition = true; }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){ $condition = true; }else{ $condition = false; } if ($CURRENT_PIC_DATA['title'] != '') { $pic_title .= $CURRENT_PIC_DATA['title'] . "\n"; } if ($CURRENT_PIC_DATA['caption'] != '') { $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n"; } if ($CURRENT_PIC_DATA['keywords'] != '') { $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords']; } if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_media, 'img_desc'); } else { if (!$CURRENT_PIC_DATA['title']) { template_extract_block($template_display_media, 'title'); } if (!$CURRENT_PIC_DATA['caption']) { template_extract_block($template_display_media, 'caption'); } } $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : ''; if ($CONFIG['make_intermediate'] && $condition ) { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal'); } else { $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize'); } $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']); $pic_title = ''; $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']); if ($mime_content['content']=='movie' || $mime_content['content']=='audio') { if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) { $CURRENT_PIC_DATA['pwidth'] = 320; // Default width // Set default height; if file is a movie if ($mime_content['content']=='movie') { $CURRENT_PIC_DATA['pheight'] = 240; // Default height } } $ctrl_offset['mov']=15; $ctrl_offset['wmv']=45; $ctrl_offset['swf']=0; $ctrl_offset['rm']=0; $ctrl_offset_default=45; $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default; $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"'; } if ($mime_content['content']=='image') { if (preg_match('/^youtube_(.*)\.jpg$/', $CURRENT_PIC_DATA['filename'],


You understand my dilema?

then when i change it back I get:

Template error
Failed to find block 'my_friends'(#(<!-- BEGIN my_friends -->)(.*?)(<!-- END my_friends -->)#s) in :

                <span class="topmenu">

<!-- BEGIN my_gallery -->
                        <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}">{MY_GAL_LNK}</a><br /><br />
<!-- END my_gallery -->

<!-- BEGIN allow_memberlist -->
                        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}">{MEMBERLIST_LNK}</a><br /><br />
<!-- END allow_memberlist -->



<!-- BEGIN faq -->
                        <a href="{FAQ_TGT}" title="{FAQ_TITLE}">{FAQ_LNK}</a><br /><br />
<!-- END faq -->





<!-- BEGIN upload_pic -->
                        <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}">{UPL_PIC_LNK}</a><br /><br />
<!-- END upload_pic -->

<!-- BEGIN register -->
                        <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}">{REGISTER_LNK}</a><br /><br />
<!-- END register -->

<!-- BEGIN login -->
                        <a href="{LOGIN_TGT}" title="">{LOGIN_LNK}</a>
<!-- END login -->


</span>


http://aro-network.co.uk/ths/HG/ <-- Site link..

If anyone would be so kind as to edit the theme.php I'm adding onto this as an attachment.. I'd love them forever.

Thanks in advance!
-Keanu

Keanu

So sorry for double posting, I don't understand why we can't just edit our posts.. /swt..

Its not attached - Its the first set of [code ] [/code ] 's

Nibbler

When you copy the function you need to put it before the ?> at the end of the file. Alternatively just leave out the ?> altogether.

Keanu

Okay done, and its all working!

Thanks!

Quick question, can I make like.. another

if (preg_match('/youtube\.com\/watch\?v=(.*)/', $YT_URI, $matches)){
$vid = $matches[1];
$xurl = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=xxxxxxxxxxx&video_id=$vid";
$xdata = file_get_contents($xurl);


And change it to;


if (preg_match('/veoh\.com\/videos\(.*)/', $YT_URI, $matches)){
$vid = $matches[1];
$xurl = "http://www.veoh.com/ * At this point i'd need some help*";
$xdata = file_get_contents($xurl);

Nibbler

Only if they have exactly the same API as youtube.

Keanu

If not, then will it not work?.. Is it possible to code a new one?.. I mean - Yeah, they have a API.. But from what I saw, it was.. Pretty damn different. xD

Thanks in advance!
-Keanu

Nibbler


Keanu


jeffnow

Hello,

OK, I got the youtube links and my movie files to work. Thanks for the link: http://forum.coppermine-gallery.net/index.php?topic=31291.msg167000#msg167000  to help me with my movies playing problem.

Now, I have another problem trying to upload pictures/ photo. I clicked at upload and the upload page load up. I then clicked on the browse and selected the picture, just one file for now. I then clicked at contiue. It stated 1 file uploaded complete. Then I need to to select the folder to put the file that I just uploaded. It then came back to the upload page. Nothing show up at the " last additions" or the new folder that i've just created.

Please, help.

Thanks again

skmdd

I had uploaded few youtube videos on my site using this mod. Youtube had disabled embedding of one of the videos which is under most viewed videos on my site. On searching youtube, I found another similar video.
Can I change the youtube video ID v=xxxxxx at the backend so that the video on my site points to this new youtube video URI?
I had a look at "cpg1411_gallerypictures" table. I could find a column with "youtube_LNVOl5_3_Zo.jpg". Would changing the video ID on this column point to the new Video URI?

Nibbler

Yeah. You'd need to fix the thumbnail too though.

skmdd

Thanks. Fixed it. I had to change youtube_xxxx.jpg file as well as thumb_youtube_xxxx.jpg file.

Elwood J. Blues

Hello !

I have a BIG problem, I need this mod and my web host has disabled the fopen function... And this mod doesn't work... I don't know if a solution exist yet but I propose my solution. I use cURL function instead of fopen function.

Search

$vid = $matches[1];
                     
$xurl = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=xxxxxxxxxxx&video_id=$vid";
                     
$xdata = file_get_contents($xurl);

file_put_contents("albums/edit/yt_$vid.xml", $xdata);

// todo: parse the xml properly
if (preg_match('/<thumbnail_url>(.*)<\/thumbnail_url>/', $xdata, $xmatches)){

$thumbnail = $xmatches[1];

$rh = fopen($thumbnail, 'rb');
$wh = fopen("albums/edit/yt_$vid.jpg", 'wb');


        while (!feof($rh)) fwrite($wh, fread($rh, 1024));

fclose($rh);
fclose($wh);


Replace with :

$vid = $matches[1];

$xurl = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=xxxxxxxxxxx&video_id=$vid";
                $ch = curl_init($xurl);   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xdata = curl_exec ($ch);
curl_close ($ch);   

file_put_contents("albums/edit/yt_$vid.xml", $xdata);

// todo: parse the xml properly
if (preg_match('/<thumbnail_url>(.*)<\/thumbnail_url>/', $xdata, $xmatches)){

$thumbnail = $xmatches[1];

$ch = curl_init($thumbnail);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xdata = curl_exec ($ch);
curl_close ($ch);   
file_put_contents("albums/edit/yt_$vid.jpg", $xdata);


Enjoy !

PS : In French http://forum.coppermine-gallery.net/index.php/topic,37970.msg246410.html#msg246410
Avant de poser une question passez par ici . 90% des réponses s'y trouvent !