Advanced search  

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]

Pages: 1 2 3 [4] 5 6 7 8 ... 22   Go Down

Author Topic: Displaying videos from Youtube in Coppermine.  (Read 372444 times)

0 Members and 1 Guest are viewing this topic.

Nibbler

  • Guest
Re: Displaying videos from Youtube in Coppermine.
« Reply #60 on: January 03, 2007, 12:39:08 am »

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.
Logged

Pascal YAP

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 13833
  • Hello World :-)
    • CPG 1.5.x ExperiMental website
Re: Displaying videos from Youtube in Coppermine.
« Reply #61 on: January 03, 2007, 02:26:13 pm »

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
Logged

carlo1

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: Displaying videos from Youtube in Coppermine.
« Reply #62 on: January 06, 2007, 07:36:11 pm »

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.
Logged

Nibbler

  • Guest
Re: Displaying videos from Youtube in Coppermine.
« Reply #63 on: January 06, 2007, 08:47:17 pm »

You must however have cURL available instead.

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

carlo1

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: Displaying videos from Youtube in Coppermine.
« Reply #64 on: January 06, 2007, 08:55:51 pm »

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.
Logged

carlo1

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: Displaying videos from Youtube in Coppermine.
« Reply #65 on: January 07, 2007, 02:53:26 am »

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.
Logged

Nibbler

  • Guest
Re: Displaying videos from Youtube in Coppermine.
« Reply #66 on: January 07, 2007, 03:03:40 am »

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

flux

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
    • CPG Remote Hack Demo
Re: Displaying videos from Youtube in Coppermine.
« Reply #67 on: January 12, 2007, 03:09:17 pm »

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 :

Code: [Select]
    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
« Last Edit: January 12, 2007, 08:33:01 pm by flux »
Logged

flux

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
    • CPG Remote Hack Demo
Re: Displaying videos from Youtube in Coppermine.
« Reply #68 on: January 13, 2007, 09:39:34 am »

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 :

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

replace it with :

Code: [Select]
    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 :
Code: [Select]
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 :
Code: [Select]
// 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:
Code: [Select]
        // First, we delete the preview image.
        if ((!strstr($preview_path, 'thumb')) and (file_exists($preview_path))) {

            unlink($preview_path);

Insert BELOW:
Code: [Select]
// 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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Displaying videos from Youtube in Coppermine.
« Reply #69 on: January 31, 2007, 09:53:55 pm »

Just like to add a thanks for this hack Nibbler.

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

puku

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Displaying videos from Youtube in Coppermine.
« Reply #70 on: February 02, 2007, 06:58:39 pm »

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
Logged

Nibbler

  • Guest
Re: Displaying videos from Youtube in Coppermine.
« Reply #71 on: February 02, 2007, 08:10:29 pm »


Code: [Select]
           // 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.
Logged

puku

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Displaying videos from Youtube in Coppermine.
« Reply #72 on: February 03, 2007, 04:32:01 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  ;)
Logged

jape

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Displaying videos from Youtube in Coppermine.
« Reply #73 on: February 03, 2007, 07:00:46 pm »

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"...

(http://img166.imageshack.us/img166/6245/gallery1bd3.gif)

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

(http://img250.imageshack.us/img250/1271/gallery2hi0.gif)

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

(http://img176.imageshack.us/img176/4689/gallery3df0.gif)

Thank you very much!  ;)

Supplement is my upload.php file....
Logged

thrower

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Displaying videos from Youtube in Coppermine.
« Reply #74 on: February 17, 2007, 02:12:00 am »

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!
Logged

thrower

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Displaying videos from Youtube in Coppermine.
« Reply #75 on: February 17, 2007, 08:54:06 pm »

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!
Logged

vascodx

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Displaying videos from Youtube in Coppermine.
« Reply #76 on: February 25, 2007, 04:24:25 pm »

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

ashelby

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 20
    • ArmedForcesPhotos.com
Re: Displaying videos from Youtube in Coppermine.
« Reply #77 on: February 28, 2007, 03:29:22 am »

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.
Logged

Nibbler

  • Guest
Re: Displaying videos from Youtube in Coppermine.
« Reply #78 on: February 28, 2007, 02:07:56 pm »

Change the theme you use
Logged

ashelby

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 20
    • ArmedForcesPhotos.com
Re: Displaying videos from Youtube in Coppermine.
« Reply #79 on: February 28, 2007, 02:40:38 pm »

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!
Logged
Pages: 1 2 3 [4] 5 6 7 8 ... 22   Go Up
 

Page created in 0.025 seconds with 19 queries.