News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Ohara YouTube Embed

Started by Suki, December 21, 2011, 03:04:59 PM

Previous topic - Next topic

Maniaka

Hello you need add tag for:

https://www....

Adrek

@up,
Quote from: Suki on December 07, 2012, 01:09:50 PM
Open Sources/OharaYTEmbed.php  and find:


(http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)


There are 2 instances of this string, make the change to both.

and replace with this:


((http|https)://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)


Back up the file first before doing the change as I haven't tested this change.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

akc42

Quote from: Suki on September 12, 2012, 06:34:12 PM
The mod doesn't modify Subs.php at all, the mod sues it's own file: OharaYTEmbed.php

Make sure the following code is presented on that file:


/* The bbc button */
function OYTE_bbc_add_button($buttons)
{
global $txt, $modSettings;

loadLanguage('OharaYTEmbed');

if (empty($modSettings['OYTE_master']))
return;

$buttons[count($buttons) - 1][] = array(
'image' => 'youtube',
'code' => 'youtube',
'before' => '[youtube]',
'after' => '[/youtube]',
'description' => $txt['OYTE_desc'],
);
}


If there is, try to change this:

function OYTE_bbc_add_button($buttons)

with this:

function OYTE_bbc_add_button(&$buttons)

I've just run over this bug having just today downloaded the latest release of this this mod. Is there a reason you haven't released a new version with this problem fixed?

Suki

Yes, there is, multiple reasons actually.

- There are other bugs that needs to be fixed too.
- Lack of time to properly build a regex pattern that will be able to cover most if not all of the new and valid youtube urls.
- Lack of interest on keep working on SMF mods.

The mod is open source so anyone can update the mod at will, anyone can redistribute modified version of this mod providing they comply with the license.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

johnpaul2k2

i had an issue with my post.php . and since then , it stop working

even i uninstalled and reinstall the mod , yet it's not working. please wat do i need to fix inside post.php or anywhere so i can use it again???

akc42

Quote from: johnpaul2k2 on March 05, 2013, 11:31:17 AM
i had an issue with my post.php . and since then , it stop working

even i uninstalled and reinstall the mod , yet it's not working. please wat do i need to fix inside post.php or anywhere so i can use it again???

Can you be more specific.  What issue with post.php and what do you mean by stop working?

If that is the only mod installed, why not un-install it and then refresh post.php from the SMF distribution you used.


johnpaul2k2

Quote from: akc42 on March 05, 2013, 12:06:58 PM
Quote from: johnpaul2k2 on March 05, 2013, 11:31:17 AM
i had an issue with my post.php . and since then , it stop working

even i uninstalled and reinstall the mod , yet it's not working. please wat do i need to fix inside post.php or anywhere so i can use it again???

Can you be more specific.  What issue with post.php and what do you mean by stop working?

If that is the only mod installed, why not un-install it and then refresh post.php from the SMF distribution you used.



i had issues with my post.php, so i removed it and added fresh post.php.
i have found out that some of my mod that got to do with post are no longer working. i removed and reinstall all of them including this Mod . but this seems not to respond.

i embedded a youtube video yet it's not working while the previous videos (before the issue came up) are all working but new one refuses to work!

akc42

Quote from: johnpaul2k2 on March 05, 2013, 12:24:17 PM
Quote from: akc42 on March 05, 2013, 12:06:58 PM
Quote from: johnpaul2k2 on March 05, 2013, 11:31:17 AM
i had an issue with my post.php . and since then , it stop working

even i uninstalled and reinstall the mod , yet it's not working. please wat do i need to fix inside post.php or anywhere so i can use it again???

Can you be more specific.  What issue with post.php and what do you mean by stop working?

If that is the only mod installed, why not un-install it and then refresh post.php from the SMF distribution you used.



i had issues with my post.php, so i removed it and added fresh post.php.
i have found out that some of my mod that got to do with post are no longer working. i removed and reinstall all of them including this Mod . but this seems not to respond.

i embedded a youtube video yet it's not working while the previous videos (before the issue came up) are all working but new one refuses to work!

You keep saying things like "has issues" or "not working" without being more specific.  When you say these words add some more detail.

When you are editing a post do you see the youtube button?

When you have [youtube]some youtube url[/youtube] in your post what is the url you use (soo we can see it) and what happens. (do you see the youtube markers or do they disappear)

Did you make these changes

Quote
If there is, try to change this:

function OYTE_bbc_add_button($buttons)

with this:

function OYTE_bbc_add_button(&$buttons)

or this one

Quote from: Suki on December 07, 2012, 01:09:50 PM
Open Sources/OharaYTEmbed.php  and find:


(http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)


There are 2 instances of this string, make the change to both.

and replace with this:


((http|https)://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)


Back up the file first before doing the change as I haven't tested this change.

Much much more detail, else we have nothing to go on to help you.

johnpaul2k2

not working

this is what i meant.  i mistakenly remove some files inside post.php and i was unable to create New Topic or Reply

i was told to remove and replace the existing post.php with FRESH post.php

i guess that's why the youtube is not working again

Suki

You never NEVER replace a file with a new fresh copy, NEVER!

What you did not only didn't solve your first issue but it has created a lot more, whoever told you to upload a fresh file just doesn't know what are doing and I will strongly suggest not to follow their advices anymore.

Follow the mod's parser and make sure you have all the proper edits on your Post.php file: http://custom.simplemachines.org/mods/index.php?action=parse;mod=3268;attach=193586;smf_version=2.0.2
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

johnpaul2k2

did as the link said but didn't work

i uninstalled and installed it back and it's working now :D

Suki

It didn't work possibly because you blindly deleted other files this mod needed.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

johnpaul2k2

sometimes, this mod will stop working

except you uninstall and install back?

why?

Suki

When you stop playing and modifying your files then the mod will cease "stop working". As simple as that.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

johnpaul2k2

Quote from: Suki on March 23, 2013, 03:36:16 PM
When you stop playing and modifying your files then the mod will cease "stop working" ;D. As simple as that.


i haven't touch any part of my file since 3 weeks now. so i do not know the problem

Suki

Care to explain more details then?  simply stating "doesn't work" or "stop working" is not really helpful.

Since you said the only thing that fixes it is reinstalling, I gotta say is not really a bug but its you messing around with your files, removing or changing things this mod needs, if that is the case, simply stopping doing it will solve your problem.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

pwhodges

#116
Since no working version of this that accepts http:// has been published, and lots of people have trouble with the button not showing (this happened to my forum recently), I thought I'd publish the corrections I have made for my own use.  To make the corrections you need to take the file OharaYTEmbed.php out of the zip file, edit in the changes, and then put it back in the zip file, replacing the original.

I have these changes running on my forum, and the code below is cut and pasted from my installed files; but obviously you make the changes at your own risk as I can't control your editing.

(1) To accept https URLs, and those with the "v=" parameter not the first:

Change both copies of the regex (in the routines OYTE_bbc_add_code and OYTE_Main) to:

'(https?://(?:www\.)?youtu(?:be\.com/watch\?(?:[\w\?=]*&(?:amp;)?)*v=|\.be/)(\w*)(?:&(?:amp;)?[\w\?=]*)*)'

Note that the regex to accept "https://" posted earlier by the author in this thread does not work; this is because the extra parentheses around the "http|https" options change the numbering of the strings collected by the regex, and this is not corrected for.

(2) To ensure that the YouTube BBC button is displayed in the editor:

This fault is because the mod uses a method of adding the button which is no longer supported in the final version of the 2.0 code; the change here uses the supported method instead (the button array is found from the context instead of being passed as a parameter). 

Change the routine OYTE_bbc_add_button to read as follows:

function OYTE_bbc_add_button($dummy)
{
global $txt, $modSettings, $context;

loadLanguage('OharaYTEmbed');

if (empty($modSettings['OYTE_master']))
return;

$context['bbc_tags'][count($context['bbc_tags']) - 1][] = array(
'image' => 'youtube',
'code' => 'youtube',
'before' => '[youtube]',
'after' => '[/youtube]',
'description' => $txt['OYTE_desc'],
);
}


I haven't tried the author's simpler suggestion of adding an & in front of the routine parameter in the original code; I had already found my correction, which works, and so have stuck with it.

I have not yet fixed the fact that smileys are not rendered following each odd-numbered video in a post, nor that quick editing of posts with no content other than the youtube tags and content fails; if I do, I will add the fixes here.


Suki

Oh, you edited your message and deleted the part where you said I won't provide more support to this.

Question is, why do I need to offer support? am I forced to do so? why do I want to keep working on a mod if I got nothing in return except complains?

People here only complains about this mod not working properly but not a single person has giving me a thank you for it, yes, this is a very small mod, however, this applies for all my modifications, people just remember you when the mod stops working or it doesn't do what you expect it to do. This whole ingratitude has pretty much driving me away.

As for your solutions.

1.- Will fail with recent and valid youtube urls.
2.- Is valid but is only valid because how SMF works by using globals vars indiscriminately. And the & thing is not solely a bug with this mod, it affects all mods that works with hooks, it has to do with passing by reference: http://www.simplemachines.org/community/index.php?topic=477624.msg3341560#msg3341560  oh and it has nothing to do with been "no longer supported on 2.0 final"  that is simple nonsense, hooks have been in SMF code as earlier as 1.1 version and the most widely used hooks are here since early RC versions of 2.0

So, yes, I no longer want to keep working on this or any other mod for that matter, it doesn't matter how much time I spent working on mods, I got nothing in return except complains.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

pwhodges

I think you for providing this mod in the first place; it is entirely up to you whether you wish to support it - in your place, I would not wish to see a faulty mod going out under my name, but whatever.  I removed my earlier comment about support because, although I'd put the link to your blog, I thought it ungracious of me to point it out, and that people could find it or not as they pleased; I apologise for highlighting it for a time.

I wanted https support, and your suggestion didn't work, so I worked out why and added it my way instead, which did.  The other regex changes I made increased the number of URLs accepted, but (as I found out today) still miss some (and the original regex would have missed the same ones as well).

The missing button; yes, your solution is better - why not put it in the download so that people don't need to think you got it wrong?  My solution (and explanation) came from another thread, and fixed the problem for me - now I know it's inappropriate I will no longer do it that way.  Thanks for the correction.  (What I don't understand is why the original, without the &, ever worked at all - which it assuredly did; this is why I rather naively accepted the story about the change of supported method.)

Arantor

Quotethat is simple nonsense, hooks have been in SMF code as earlier as 1.1 version and the most widely used hooks are here since early RC versions of 2.0

Hate to contradict you but that's not entirely accurate.

The hook system in 1.1 and all the way up to 2.0 RC3 could only support one function call per hook. There are a few extra hooks in 2.0 for things like the menu, the bbc handling and so on, but these were introduced in 2.0 RC4 along with the other hook changes like multiple functions per hook.

QuoteI haven't tried the author's simpler suggestion of adding an & in front of the routine parameter in the original code; I had already found my correction, which works, and so have stuck with it

Putting the & in front of the variable inside the function declaration is the correct way to handle such things.

QuoteWhat I don't understand is why the original, without the &, ever worked at all

Because PHP 5.2 allowed it, PHP 5.3 deprecated it, PHP 5.4 doesn't support it at all. When this mod was originally developed, PHP 5.4 was not exactly what you would call widespread.

QuoteSo, yes, I no longer want to keep working on this or any other mod for that matter, it doesn't matter how much time I spent working on mods, I got nothing in return except complains.

This is why I stopped writing mods for SMF, I fully sympathise. It seems like no good deed goes unpunished.

Advertisement: