User Video Embedding in Rails 3 - ruby-on-rails

I am building an app using Rails 3 that allows users to submit videos. I would like to be able to accept simply the video URL from the user and using this, my app will generate the appropriate embed code (depending on the video source). Is there a good library for something like this that already exists? I'd rather not have to reinvent the wheel here and write my own regex/scripts to embed the videos if something already exists.
Think of how tumblr works...you just paste in the url of the video and it embeds it all automatically.
Thanks!

I would look into the embedly api it may be able to address your problem.

Related

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.

Videos URL structure with nothing but a date in it to keep every video shareable?

what is the approach to store multiple videos from an author in his named folder, but then there are 1-n videos from this author?
YouTube has for every video a complete different URL with an ID. Casual/Older users don't know where they are.
News sites seem use /topic/title-id123
Cnn uses /yyyy/mm/dd/title
To keep this question answerable: What URL structure would you recommend for me?
- every person has some videos without interesting title we could use
- the date from start day to end day is more likely important (2005-12-12 to 2005-12-17)
- every video should be social media shareable, so I think they all need a single URL and can't just be all embedded in /videos/name
Store them however is the best for the backend editor workflow (you didn't mention, how and when new videos are added), in 6.2 you have file abstraction layer, so each file in fileadmin has assigned ID. If you want to make your videos nicely social media sharable, you need to provide additional metadata such as video name and thumbnail etc, so I would suggest building a plugin for this which would take the video ID from the URL and display it with all the additional data necessary.
If you are using EXT:realurl (which I hope you are), you can configure to the video title in the URL, which would look like: /somepage/video/video-title/ or even /somepage/video-title/ . Adding /yyyy/mm/dd/ in the URL only makes sense if you are producing multiple videos every day, otherwise it feels pointless.
for building unique URLs with realurl for news you find solutions to include the uid of the news.
As TYPO3 handles all files with FAl you might use the unique file_sys:uid in your video URL. You might use realurl to generate and resolve URLs like:
/videos/123/title_of_video/

How do I grab meta data from other websites and display on mine in ruby on rails?

When using FB or Google + I can paste a link of any website into the status update box and it will instant load information about that website with the option of flicking through thumbnail images.
How can I go about achieving this in ruby on rails? All my searches seem to bring up php methods on how to do this.
For grabbing video data info I use the Ruby Open Graph Protocol gem. Is there any thing for grabbing data the way FB and G+ do? If not is there a standard way this is done in rails/ruby, if so.. how is this done?
Kind regards
I think you're looking for something like oembed. I've found a gems for that, so I propose you to take look at it: https://github.com/judofyr/ruby-oembed or https://github.com/embedly/embedly-ruby
You should likely use a gem like http://nokogiri.org/
It allows you to work with a html page just as you would do with jQuery. Very handy.

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.

Rails 3 different types of embeds under one controller

I have a rails app that I am looking into implementing videos. I know how embed the videos etc but I am confuse on how to do something like this.
I would like a user to have videos. When a users goes to add a video I want to give them the option of embedding a youtube video or a vimeo video(Should I write out if statement?) without having 2 completely different urls.
For example
If user embeded a youtube video url would look like this
mysite.com/videos/1/youtube/1
If a user were to add video it would look like this
mysite.com/videos/1/youtube/new
What I would like to implement is the user would go to video and then have the choice of choosing vimeo or youtube. Ater the user has input the url of the video and click create i would like urls to look like(whether its youtube, vimeo or uploaded from cpu)
mysite.com/videos/1
mysite.com/videos/new
What is the best way to approach this? Would it be nested resources then rewrite the url paths?
There are many solutions to this problem and I ended up using gem called oembed to handle processing of embedded files from youtube, vimeo etc.
figured this out forgot to update question. Check out solution here
Vaildate 1 field with mutiple options
From a RESTful perspective, the resource that you are requesting is the video. The mechanism of how that video is requested (whether that is Vimeo or Youtube) is irrelevant from the perspective of identifying the resource. The format of the video being requested is simply a parameter of the request. In your controller, you can decide how to render the video based on the parameters (or potentially other aspects of the request header). Your video should clearly exist as a resource as
mysite.com/videos/1
Let the parameters or the HTTP request dictate how that is rendered.

Resources