Best YouTube gem for Ruby?
found a list of alternative github clients. maybe they do a better job:
- http://github.com/dennmart/youtube_rest/tree/master
- http://github.com/edgarjs/youtube-model/tree/master
- http://github.com/mikedamage/ruby_tube/tree/master
source: http://railsforum.com/viewtopic.php?id=33219
search for and embed youtube videos in ruby on rails application
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.
How to get YouTube video details through the API into a Rails app?
Ruby gem to get information from vedio. Check out this link. https://github.com/thibaudgg/video_info
gem install video_info
video = VideoInfo.new("http://www.youtube.com/watch?v=mZqGqE0D0n4")
# video.available? => true
# video.video_id => "mZqGqE0D0n4"
# video.provider => "YouTube"
# video.title => "Cherry Bloom - King Of The Knife"
# video.description => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
# video.duration => 175 (in seconds)
# video.date => Sat Apr 12 22:25:35 UTC 2008
# video.thumbnail_small => "http://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg"
# video.thumbnail_medium => "http://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg"
# video.thumbnail_large => "http://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg"
# video.embed_url => "http://www.youtube.com/embed/mZqGqE0D0n4"
# video.embed_code => "'<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>'"
framework and aprroach to get youtube insight data using ruby
I spent some time working on this over the weekend. Youtube-Model seems to work the best:
Use example in youtube model to get authsub token
yt = YouTubeAccess.uploaded_by_user(token)
yt_videos = yt.videos
yt_videos.each{|video|
view_count = video.statistics.viewCount.to_i
favorite_count = video.statistics.favoriteCount.to_i
comment_count = video.comments.attributes['feedLink'].countHint.to_i
}
Not sure how to do channels, but this is a good start.
Stream youtube sound via Ruby?
Seems to be an intersting project, so I searched a little. From this reddit post: Tip: Use mpv + youtube-dl as streaming audio player there's this code using the mpv
program to stream audio:
mpv "https://www.youtube.com/watch?v=sVK5Z6wnMxg" --no-video
That URL is a livestream of the Bonaroo music festical that's currently happening. I tried it and it does start the audio. Under the hood this is using youtube-dl which has this note in the man page:
How do I stream directly to media player?
You will first need to tell youtube-dl to stream
media to stdout with -o -, and also tell your me‐
dia player to read from stdin (it must be capable
of this for streaming) and then pipe former to
latter. For example, streaming to vlc
(http://www.videolan.org/) can be achieved with:youtube-dl -o - "http://www.youtube.com/watch?v=BaW_jenozKcj" | vlc -
So if you wanted to pass the stream to a different media player, that would be a good place to start.
In terms of Ruby; well, this isn't really a Ruby solution per se, and you'd simply call the shell program from Ruby using backticks, system
, Process.spawn
, fork
, etc.
Strategies for Integrating Youtube in a Rails 3 App
A little Google search turned out a Rails plugin that uses Google AuthSub with YouTube so to answer your first question, I don't think it's necessary to rewrite code (Don't reinvent the wheel ;))
Regarding the usability direction, I think it depends on the webapp you'll be building. Is it a social app where user profiles are important? If so, I'd go with the first approach. Is it a corporate app with tutorials for employees? The second approach would work better, in my opinion.
EDIT:
Here's another Youtube Gem which, according to the author last commit, should have compatibility with Ruby 1.9
youtube api for rails 3
http://railsforum.com/viewtopic.php?id=33219
Query YouTube API (v2 vs v3) for Titles
Best way is to use Data API v3 videos->list call. You can join all video id's with a comma for batching. I used three video ids below as an example
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=iXOUIsu-E0Q%2C+LWoBXHDeJSY%2C+Xz5z1hBxejg&fields=items%2Fsnippet&key={YOUR_API_KEY}
Related Topics
Ruby on Rails Error "Cannot Load Such File -- Less"
Full Url for an Image-Path in Rails 3
Why Pg::Uniqueviolation: Error: Duplicate Key Value Violates Unique Constraint
How Mix in Routes in Sinatra for a Better Structure
Creating Routes with an Optional Path Prefix
Embedding JSON Data into Yaml File
What Is '$:.Unshift File.Dirname(_File_)' Doing
Where in the Ruby Language Is %Q, %W, etc., Defined
Iterating Between Two Datetimes, with a One Hour Step
Executing User-Supplied Ruby Code on a Web Server
How to Get a Stack Trace Object in Ruby