search for and embed youtube videos in ruby on rails application - ruby-on-rails

I have a website where I want to basically allow people to display several youtube videos onto the same page.
For example, I have a friend who has 3 different videos. Instead of sending a link to the three videos individually, they would go to my site see the 3 search boxes, search for the videos individually (the search is done on youtube), then they can pick the videos and click "done", at which point, the 3 videos would be embedded on their page.
I'm trying to figure out how to approach this in ruby on rails, but I'm not finding much information on how.
Here's a link from 2009 of a guy who's saying that he can actually do the search and retrieve from youtube: http://railsforum.com/viewtopic.php?id=30443
But I don't know how to do the search & retrieve, and I don't know how to do the embed. I think I can figure out the embed, but what's the best way to do the search/display results?
Thanks a lot for your help stackoverflow, you're my only hope (besides google, but google failed me today).

all you need to know about the search feature is described in YouTube Data Api. You will need your app to communicate with this API. The best thing to do may be to look after a gem specialized in this ; there is a list available in another StackOverflow question.

Related

How to get specific results using MediaWiki API in Rails backend?

I'm doing my final project for a coding school that will be a deep song search app that returns every detail about a song (composer, personnel on the track, lyrics, studio, media uses, images, etc). I'm using React frontend/Rails backend API. I'm new to API's and have tried Discogs and Musicbrainz but find the Mediawiki to be the easiest to traverse. Messing with their sandbox using Query, I feel like I'm getting closer but wondering if anyone with more experience out there could help me get precisely what I need.
I would like a music search to return a list of matches (could be same title but different songs or same title but different recordings). A user can click on the results to see the details. I would like the API to return links and hopefully images (album cover, etc). Does anyone know the best way to go about this?
I've also tried using the Ruby Gem wrapper Mediawikitory https://github.com/molybdenum-99/mediawiktory. I like the clean interface but can't quite find the right parameters.
The closest I've come to what I'm looking for in the Mediawiki sandbox is an example like this for the All Star (Smash Mouth):
https://en.wikipedia.org//w/api.php?action=query&format=json&prop=&list=search&continue=-%7C%7C&srsearch=star%20(song)&srlimit=5&sroffset=15&srqiprofile=engine_autoselect&srwhat=text&srinfo=totalhits%7Csuggestion%7Crewrittenquery&srinterwiki=1
This gives a list of songs (I'll have to concatenate '(song)' in every search unless there's a specific category parameter I don't know about).
So with further research I was able to drill down to specific song searches (and this will work for any thing this specific). You have to use srsearch and then search option in lists. So an example for a list of songs based on a given title:
https://en.wikipedia.org/w/api.php?action=query&formatversion=2&format=json&prop=info%7Cpageimages&generator=search&inprop=url&piprop=thumbnail%7Cname&gsrsearch=I%20love%20you%20(song)&gsrwhat=text
Make sure you choose version 2 as it gives you a better formatted Object to map over.
The Mediawiki API is very robust. You just have to spend a little time with it. The sandbox is great.

Adding multiple youtube playlists to site just like youtube has em

this is desired output for site
this is how youtube displays multiple playlist...how can I add this just like they have it to my site AND to linkedin profile?
embedding the share html link just brings in playlist but it does not display properly....I need it to appear exactly like it does in attached pic???
Linking to your LinkedIn profile, I have not tried. So perhaps someone else can tell you.
As to having a section like the one you showed to be on your own site is doable.
Firstly you will need to collect the playlist ID's that you are going to use.
Then you will need to get the video ID's from the video's in each Playlist.
This can be done with the API.
As to the displaying it like on youtube, you will need to do that yourself with one or more combination of table's, div's and CSS. Then With the information you grabbed in the APi, populate it.
Best to do it in a loop so as to be done all at the same time. Then put it to the page where you require it to be.

How to intergrate a single tweet into your website

Right now im building a simple html/css site for a friend. The homepage is a series of grid block divs that hold some content.
There are currently 3 block divs we have marked for social media posts. So for example, he wants his latest tweet to appear in one of those divs. His latest instagram post to appear in another and facebook in the last.
We can ignore facebook for the time being as I'm only focusing on the twitter/instagram for now.
I'm struggling with where to begin for this project. In the past I have only embedded twitter timelines, Instagram posts using widgets etc....nothing too complicated.
But for this project I will need separate stripped down posts, ie: just the plain text from his tweet inside the twitter div. The image from his Instagram post as the background image on the Instagram block etc...
I've spent the last few hours trying to get my head around oEmbed, and I can safely say I'm failing miserably.
I'm actually more confused now then before I started, so if any kind soul could give me a dummies guide to how I can approach this, that would be absolutely amazing.
Thank you!
You can acheive a single embedded tweet using an embedded timeline.
To get just one tweet, use the data-tweet-limit attribute on the embed tag, as detailed here:
https://dev.twitter.com/web/embedded-timelines/parameters
For example:
<a class="twitter-timeline" href="https://twitter.com/TwitterDev" data-widget-id="some_id" data-tweet-limit="1"></a>
According to twitter's documentation, that is the recommended way of getting tweets onto websites. From your description of the use case, I'd highly recommend just using Twitter's official widget.
If you really want to use Twitter's REST API and generate your page server side, I'd check out this stack overflow question as a starting point:
Setting up Twitter API, getting the last few Tweets
Hope that helps!

Youtube Search Results as Playlist, Need Advise

Hi guys, this is my first time to post on this awesome community so
please bear with me.
I am working with a Wordpress Plugin that can display a Youtube Search Results into Video Playlist.
My settings are:
Keywords
Author
Content- channel/keyword
My first Approach was this:
with this api as reference,
search for the keyword > display the relevant results according to the author as playlist
*I'm in doubt if I this is possible, coding 30%
*I'm not sure where could I use my settings for Content
but then when my coding is in progress I recently bumped an article that says Youtube Search is differrent on Searching a Youtube Playlist
Now I can't continue my coding because I'm not sure If I'm doing it
right. Can you give me some advise with this situation or show me some
similar project/examples?
You don't have to write any YouTube Data API code for this; it's a built-in feature of the YouTube Player.
This blog post has an example of loading a list player that takes its content from the recent uploads of a channel. You can do something similar by setting listType=search&list=SEARCH_TERM, where SEARCH_TERM is whatever string you want to search for (be sure to URL escape it). You can read more in the documentation.

How to allow users to embed YouTube & Vimeo videos?

How can I go about allowing users to embed YouTube and Vimeo videos in my Rails app?
I'd provide a text field or text area where users can add the link of the video they wish to embed.
Click add and have my app show a spinner while the details are being gathered.
When the details are found, I'd want them displayed on the page before user can finally submit the post.
I'm guessing the HTML, link details will need to be stored in the database so the video can automatically be displayed every time the page is visited.
HTML5 has a file API that gives me the ability to display users local file data on the fly. Wondering if there is something similar for display remote data or would normal ajax be used?
Is there a standard way of doing this? Also are there any tutorials out there on how to do this in rails? Would like to go about doing this in the most safest and securest way.
I love tutorials and screencasts so I'd really be thankful for info on where I can find one to achieve what I'm trying to achieve.
Try to use open graph protocol to fetch site information before user sending the form.
I suggest the following gem:
https://github.com/intridea/opengraph
Open graph protocol:
http://ogp.me/
And I guess you should store all the fetched information in database.
The Video Thumb gem is probably what you are looking for.
It handles vimeo, youtube and potentially others.
Then you just do:
<%= VideoPlayer::player(library_item.url, 700, 420).html_safe %>
In your view to display an automatically generated embed code.

Resources