collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 240
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: Recently attached video  (Read 10939 times)

0 Members and 1 Guest are viewing this topic.

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Recently attached video
« on: November 09, 2011, 10:05:36 AM »
Hi there gang!

Is it possible to create a block with custom code that will display most recently attached (embed in post) video?

Thanks !

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #1 on: November 09, 2011, 03:28:13 PM »
Various ways to do that, but are you using Aeva Media to embed videos?

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #2 on: November 09, 2011, 04:31:24 PM »
Thanks for the reply. Yes in this instance forum is supported by Aeva Media. Just to clarify ... I do not want to post most recent / random video from Aeva Media gallery. It has to be most recent / random video posted on the forum.

Regards

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #3 on: November 09, 2011, 04:46:28 PM »
Is this on post-basis or thread-basis?

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #4 on: November 09, 2011, 04:51:04 PM »
Ideally on posts but both versions (post - thread) would be much appreciated for testing purposes ;)

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #5 on: November 09, 2011, 05:21:45 PM »
The way I'm thinking of doing this is to call the recentPosts() function that SMF uses to acquire a list of recently made posts, and then use a regex on it to search the posts for an embed, and then list the most recent one and pass it on (and cache it).

The only problem is that if no embedding has happened for a while, then there is a possibility that it won't show any post, since none would have any. In that case you would need to check every possible post, or just rely on the old cache of the last video (which is far better).

What BBC are you using to embed videos, if any at all?

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #6 on: November 09, 2011, 05:43:00 PM »
Here, try this out. It should work properly in a sense, it is made for YouTube videos really (though it should detect other swfs fine).

Code: [Select]
<?php

if (!cache_get_data('recent_video'))
{
$posts ssi_recentPosts(150nullnull'array'false);

$search '';
foreach ($posts as $post)
$search .= $post['body'];

$matches = array();
preg_match_all('%http://(?:\S+\.swf\b|\S+?youtube\S+)%'$search$matches);
cache_put_data('recent_video'$matches);
}
else
$matches cache_get_data('recent_video');

if (!empty(
$matches) && !empty($matches[0][0]))
echo str_replace(array('"''&quot;'), ''$matches[0][0]);

?>

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #7 on: November 09, 2011, 05:51:29 PM »
Just a btw: since it has to run a rather large regex on all posts for a match, it's cached forever. I just realized that because of this, it won't update when someone makes a new post unless you dump out the cache.

You can make it automatically dump out every xxx seconds or so, I would recommended every 3 or 6 hours.

To do this (for 3 hours), in my code find the following lines:

Code: [Select]
if (!cache_get_data('recent_video'))
Code: [Select]
cache_put_data('recent_video', $matches);
Code: [Select]
$matches = cache_get_data('recent_video');
And replace each one with the equiv:

Code: [Select]
if (!cache_get_data('recent_video', 10800))
Code: [Select]
cache_put_data('recent_video', $matches, 10800);
Code: [Select]
$matches = cache_get_data('recent_video', 10800);

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #8 on: November 09, 2011, 05:56:21 PM »
Sweet ! unfortunately it is calling and displaying raw link without showing the actual video  :(
And there is no bbc coding around it as far I am aware of. The only support for displaying the images and videos is Aeva Media.

Thank you
« Last Edit: November 09, 2011, 06:00:09 PM by yaosurfer »

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #9 on: November 09, 2011, 05:59:35 PM »
Hmm. Not sure where Aeva Media picks up the tags from, thought it was some giant url buffer edit or something, maybe it uses parse_bbc or similar.

Try this, and see if it shows the video,

Find:
Code: [Select]
echo str_replace(array('"', '&quot;'), '', $matches[0][0]);
Replace with:
Code: [Select]
echo str_replace(array('"', '&quot;'), '', parse_bbc($matches[0][0]));

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #10 on: November 09, 2011, 06:03:00 PM »
I did something:
- used to be raw/plain text
- after the change the text is displayed as a "link type" therefore when mouse-over, it will simply underline the link (able to click the link)

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #11 on: November 09, 2011, 06:05:47 PM »
So it hyperlinked it, huh?

I'm not sure what Aeva Media does to display the actual embed. You could ask the author about it (I'm sure they can tell you what you need to do easily), or you could manually edit the HTML embed in there.

You can add HTML to it as such:
Code: [Select]
echo '<html tags>' . str_replace(array('"', '&quot;'), '', $matches[0][0]) . '</other html tags>';

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #12 on: November 09, 2011, 06:14:31 PM »
The code is pulling the link from the forum so definitely this is a good start. Now the question is how to display it. Unfortunately I am not a coder :( Thanks for support Classic Sonic!

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #13 on: November 09, 2011, 06:16:08 PM »
Well, that's a good sign. I'm looking at Aeva now and have tried some variations of using its functions to display a specific url to match, but it doesn't seem to be easy.

If this was only for YouTube links, I can easily make it work. Is that okay?

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #14 on: November 09, 2011, 06:19:23 PM »
The most common are youtube and vimeo.

- any website would be supercalifragilisticexpialidocious
- youtube and vimeo I could cry from happiness
- youtube I will be more than happy

Thanks !

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #15 on: November 09, 2011, 06:35:33 PM »
Find:
Code: [Select]
if (!empty($matches) && !empty($matches[0][0]))
echo str_replace(array('"', '&quot;'), '', $matches[0][0]);

Replace with:
Code: [Select]
if (!empty($matches) && !empty($matches[0][0]))
{
$video = str_replace(array('"', '&quot;'), '',  $matches[0][0]);

echo '<object width="300" height="250"><param name="movie" value="', $video, '&hl=en&fs=1&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><embed src="', $video, '&hl=en&fs=1&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowfullscreen="true" width="300" height="250"></embed></object>';
}

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #16 on: November 09, 2011, 07:59:22 PM »
Yeap it works .... only youtube but it does the job. Thank you Classic Sonic! :applause:

Btw if anyone have an idea how to embed vimeo (or any other video sharing website) please add it here   ;)

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #17 on: November 10, 2011, 11:57:09 AM »
I just found one small problem with this code ....  :'(

Just investigated a little bit further. And now I see empty space. There might be 2 reasons for that:

1. With this seconds setup ... it will hold the video for that time but after it runs out .... it leaves blank
eg. if it is set on 1h it will check for new vid every 1h, if it wont find any ... it will show empty space

2. someone post a link with youtube inside of it (but it is not related directly to video)


Is there a simple fix for it ?

Thank you
« Last Edit: November 10, 2011, 11:59:52 AM by yaosurfer »

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Recently attached video
« Reply #18 on: November 10, 2011, 05:34:27 PM »
Try clearing your cache, for starters.

If you used a timed cache like above, then the cache is automatically emptied in order to show the last video.

I suppose I could modify it to insert yet another variable into the cache to remind itself, if you want.

I don't understand what you mean in 2

Offline yaosurfer

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #19 on: November 10, 2011, 05:53:59 PM »
Yeap clearing the cache of the entire forum did the trick. But I prefer to be it rather automatic and like you mentioned "remind it self".

not a coder here .... but I assume that the code above search the forum for eg. "word word youtube word word" and it will try to load it anyway? I came to that conclusion after someone posted a link to youtube play list. And that's when things started to go wrong.

After all I am not sure about the main reasons of "empty block" ... but I would be grateful for solution.

Thanks

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #20 on: December 21, 2011, 09:19:32 AM »
I want to use same coding to bring/search Youtube videos on portal.

But I have two different video boards and I would like to add only one

board's video on portal so how can I make changes that only specific

boards video appear on portal?

Offline nontanun

  • Newbie
  • Posts: 3
  • SMF Version: 2.0
  • SP Version: 2.3.3
Re: Recently attached video
« Reply #21 on: March 08, 2012, 03:29:13 AM »
Sorry about my English.
please help I want mor Recently attached video 3 or more.
thank you Leekoberries.




Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: Recently attached video
« Reply #22 on: March 08, 2012, 02:56:47 PM »
Sorry about my English.
please help I want mor Recently attached video 3 or more.
thank you Leekoberries.




I want to use same coding to bring/search Youtube videos on portal.


Would you please start you own seperate topics for the requests otherwise these will go unanswered if unseen.
But I have two different video boards and I would like to add only one

board's video on portal so how can I make changes that only specific

boards video appear on portal?
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast