Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Auto Youtube Link-Converter Details »»
Auto Youtube Link-Converter
Version: 1.4, by Disasterpiece Disasterpiece is offline
Developer Last Online: Oct 2019 Show Printable Version Email this Page

Category: Mini Mods - Version: 4.1.2 Rating:
Released: 03-31-2011 Last Update: 05-22-2011 Installs: 795
Uses Plugins
Re-useable Code  
No support by the author.

So basically this is a total easy-to-implement plugin, which converts standard youtube links to video-embeds on the fly without urging users to use the video-button because I think it is unnecessary.


On post display, the plugin checks if the post contains at least 1 youtube link in the form of
Code:
<a href="http://www.youtube.com/watch?v=somecode&some=params">http://www.youtube.com/watch?v=somecode&some=params</a>
and converts them using the default vB video bbcode parser.

Code can be modified to fit your needs, altough there shouldn't be much to add.
If you're the special performance-freak, I'm curious if you can enhance data/query-performance. So let me know if you do.

INSTALL:

- Download attached XML File and import it as an addon.

Code:
Changes since 1.3:
- Now works properly on iPad

Changes since 1.2:
- Supports mobile devices with fallback-display if browser doesn't support flash/embed codes
- Allows the user to specify the above mentioned replacement code for mobile browsers
- Minor improvements & Fixes

Changes since 1.1:
- Moved regular expression and index position into admincp settings to allow easier changing in the future
- supports new youtube link format: "http://youtu.be/*somevideocode*"

Changes since 1.0: (or: why should I download that mod again?)
- Added Link parsing in post-preview mode and in post reviewbits (the latest posts you see under the new reply form)

Now every post containing youtube-links should display the embedded video instead.
Works with any number of youtube-links and any kind of text surrounding them.

Let me know if you have trouble/questions.

Download Now

File Type: xml product-autoytparser_1_1.xml (2.7 KB, 365 views)
File Type: xml product-autoytparser_1_2.xml (4.3 KB, 190 views)
File Type: xml product-autoytparser_1_3.xml (7.8 KB, 251 views)
File Type: xml product-autoytparser_1_4.xml (7.8 KB, 3453 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 04-06-2011, 01:26 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
So, I simply execute that PHP file you attached and it will go through our entire database, altering them to something else?
Correct. Keep in mind that the execution starts the moment you open the url in your browser. So enter the database credentials before you run the url.

Quote:
I have no database prefix .... it just shows in the config file for vBulletin as ' ' with no prefix in between the single quotes. Just leave it as two single quotes in your PHP file?
Righto, just leave it as '' then. (without space)

Quote:
BTW, my language is English ..
I know, just wanted to point that out in case other users want to use the script as well
Reply With Quote
  #33  
Old 04-06-2011, 08:55 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Disasterpiece View Post
Correct. Keep in mind that the execution starts the moment you open the url in your browser. So enter the database credentials before you run the url.

Righto, just leave it as '' then. (without space)
Understood ... will try this out after a full backup and advise ...

Regards,
Doug
Reply With Quote
  #34  
Old 04-07-2011, 02:58 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BadgerDog View Post
Understood ... will try this out after a full backup and advise ...

Regards,
Doug
Hi....

Entered our specific information, backed up and then executed PHP file.

All it came back with was the phrase No query result and no [youtube] records weres changed?

Am I doing something wrong?

Regards,
Doug
Reply With Quote
  #35  
Old 04-07-2011, 05:46 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

give me a few examples how your youtube tag works and I'll try to sort it out
Reply With Quote
  #36  
Old 04-07-2011, 06:09 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Disasterpiece View Post
give me a few examples how your youtube tag works and I'll try to sort it out
Special BBCodes were added to our site over the years so that they appear in posts like this:

[youtube=QT7kEMxSdZU]British Training Film[/youtube]

.. or, like this ...

[youtube]QT7kEMxSdZU[/youtube]

Now, these videos appear twice (they repeat) in each post with your excellent new YouTube mod installed, except yours presents a wide screen video, where the old ones were 4x3. Yours is better.....

Is this what you mean by examples?

Regards,
Doug
Reply With Quote
  #37  
Old 04-07-2011, 07:05 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then modify the convyt.php like the following:

Replace the $ytpreg = ... line with each one of those:
PHP Code:
$ytpreg "/\[youtube=([a-zA-Z0-9_-]+)\&?\](.*)\[\/youtube\]/i";
$ytpreg "/\[youtube\]([a-zA-Z0-9_-]+)\&?\[\/youtube\]/i"
You'll have to run the script 2 times, each time with one of those lines.

That should do the trick then.
Reply With Quote
  #38  
Old 04-07-2011, 09:15 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Disasterpiece View Post
Then modify the convyt.php like the following:

Replace the $ytpreg = ... line with each one of those:
PHP Code:
$ytpreg "/\[youtube=([a-zA-Z0-9_-]+)\&?\](.*)\[\/youtube\]/i";
$ytpreg "/\[youtube\]([a-zA-Z0-9_-]+)\&?\[\/youtube\]/i"
You'll have to run the script 2 times, each time with one of those lines.

That should do the trick then.
Hi...

I changed the individual line as above and created two different PHP files. I then ran each one and in both cases, the PHP execution returned No query result.....

I'm not sure what else could be wrong because the BBCode it should be locating is exactly as above, but if I emailed you the three files, one of which would be my config.php for vBulletin, perhaps could have a quick look?

Appreciate your support .... :up:

I did notice that your PHP file refers to:

$database = xxxxx

.. but then the line that opens the database says:

$db = mysql_connect($host, $username, $password);
mysql_select_db($database_name);

Is that correct? .. or should it be:

mysql_select_db($database);

Regards,
Doug
Reply With Quote
  #39  
Old 04-07-2011, 11:48 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

heh, I'm afraid you're right. Must've missed that.

ofc
PHP Code:
mysql_select_db($database); 
would make more sense. Try that out.

cheers
Reply With Quote
  #40  
Old 04-08-2011, 12:05 PM
alfanexus alfanexus is offline
 
Join Date: Dec 2008
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Would be great if this also worked in blogs and not just forums
Reply With Quote
  #41  
Old 04-08-2011, 02:03 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Disasterpiece View Post
heh, I'm afraid you're right. Must've missed that.

ofc
PHP Code:
mysql_select_db($database); 
would make more sense. Try that out.

cheers
Yup ... :up:

That got it running, although after passing 150,000 posts and then checking one with a duplicate, the post content using this BBCode syntax still shows a duplicate. Your real-time wide screen conversion, plus the old BBCode using this syntax.

[youtube]-QIO_G9gs0A[/youtube]

I'm using these (one at a time):

Replace the $ytpreg = ... line with each one of those:
PHP Code:
$ytpreg "/\[youtube=([a-zA-Z0-9_-]+)\&?\](.*)\[\/youtube\]/i";
$ytpreg "/\[youtube\]([a-zA-Z0-9_-]+)\&?\[\/youtube\]/i"
Any ideas?

Thanks ..

Regards,
Doug
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06861 seconds
  • Memory Usage 2,370KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (5)bbcode_php
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (13)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (4)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete