Giter Site home page Giter Site logo

yt's People

Contributors

andrewroth avatar brianlu365 avatar claudiob avatar dgb avatar efremroberson avatar grafikart avatar jacknguyen avatar jcohenho avatar jdwolk avatar jules-w2 avatar kalemi19 avatar kangkyu avatar kieranp avatar kxcrl avatar lostapathy avatar matuag avatar mdesantis avatar motai avatar philipqnguyen avatar rickpern avatar rrrene avatar stavro avatar stefansundin avatar timzero avatar treble37 avatar vkhang55 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yt's Issues

Make tests faster

Some request specs that hit the YouTube API are inherently slow because they have to wait for YouTube to expire the cache. However, we can at last add the :slow RSpec tag to them and add some rake task to skip them if the related code was not touched. As of August 11th, 2014 these are the slowest tests:

Top 10 slowest examples (158.7 seconds, 39.9% of total time):
  Yt::Models::Channel given someone else’s channel that I am subscribed to should be truthy
    22.79 seconds ./spec/requests/as_account/channel_spec.rb:42
  Yt::Models::Channel given someone else’s channel that I am not subscribed to should be truthy
    22.61 seconds ./spec/requests/as_account/channel_spec.rb:36
  Yt::Models::Channel given someone else’s channel that I am not subscribed to should equal false
    22.29 seconds ./spec/requests/as_account/channel_spec.rb:35
  Yt::Models::Video given one of my own *private* videos that I want to update passing the parameter in underscore syntax only updates the timestamp to publish the video
    14.7 seconds ./spec/requests/as_account/video_spec.rb:342
  Yt::Models::Video given one of my own *private* videos that I want to update passing the parameter in camel-case syntax only updates the timestamp to publish the video
    14.29 seconds ./spec/requests/as_account/video_spec.rb:353
  Yt::Models::Video given one of my own videos that I want to update returns valid reports for video-related metrics
    13.47 seconds ./spec/requests/as_account/video_spec.rb:298
  Yt::Models::Channel given my own channel returns valid reports for channel-related metrics
    12.7 seconds ./spec/requests/as_account/channel_spec.rb:87
  Yt::Models::Account.upload_video given the path to a local video file should be a kind of Yt::Models::Video
    12.57 seconds ./spec/requests/as_account/account_spec.rb:40
  Yt::Models::Account.upload_video given the URL of a remote video file should be a kind of Yt::Models::Video
    11.99 seconds ./spec/requests/as_account/account_spec.rb:46
  Yt::Models::Channel given someone else’s channel that I am subscribed to should equal true
    11.29 seconds ./spec/requests/as_account/channel_spec.rb:41

Top 10 slowest example groups:
  Yt::Models::Channel
    4.59 seconds average (132.97 seconds / 29 examples) ./spec/requests/as_account/channel_spec.rb:5
  Yt::Models::Account
    3.39 seconds average (27.08 seconds / 8 examples) ./spec/requests/as_account/account_spec.rb:4
  Yt::Models::Request
    2.31 seconds average (30.04 seconds / 13 examples) ./spec/models/request_spec.rb:5
  Yt::Models::Video
    2.23 seconds average (75.79 seconds / 34 examples) ./spec/requests/as_account/video_spec.rb:6
  Yt::Models::Playlist
    1.16 seconds average (34.93 seconds / 30 examples) ./spec/requests/as_account/playlist_spec.rb:6
  Yt::Models::Account
    0.98466 seconds average (1.97 seconds / 2 examples) ./spec/requests/as_content_owner/account_spec.rb:5
  Yt::Models::ContentOwner
    0.79088 seconds average (11.86 seconds / 15 examples) ./spec/requests/as_content_owner/content_owner_spec.rb:4
  Yt::Models::Resource
    0.71494 seconds average (1.43 seconds / 2 examples) ./spec/requests/as_account/resource_spec.rb:4
  Yt::Models::PlaylistItem
    0.71161 seconds average (1.42 seconds / 2 examples) ./spec/requests/as_account/playlist_item_spec.rb:4
  Yt::Models::Channel
    0.58503 seconds average (27.5 seconds / 47 examples) ./spec/requests/as_content_owner/channel_spec.rb:5

Randomized with seed 63790

Is there any age restriction for the video

Is there any method to know age restriction for the video. I tried like this
video = Yt::Video.new url: 'https://www.youtube.com/watch?v=p5Lj3y3mOxw'
video.annotation.above? 50
error: NoMethodError: undefined method `annotation' for #Yt::Models::Video:0x007f30d62b34b0

video.annotations.above? 50
error: NoMethodError: undefined method `annotation' for #Yt::Models::Video:0x007f30d62b34b0

Uploading video to app owner's youtube account.

Hi I have used yt gem and I figured out that videos are uploaded to oAuth2 authenticated user's youtube account.
But I want to know if there is a way to upload video to registered app owner's youtube account not logged in user's youtube account.
Please let me know if there is a way to do that.
Thanks.
Petko.

Uploading to a video path as in Youtube_it

Considering a client server scenario where yt is working on the server.
I don`t want to transfer the whole file to the server, but to have a javascript that uploads it directly from the client.

There is an example for youtube_it - http://www.sitepoint.com/uploading-videos-youtube-rails/
where you upload metadata of the video to youtube from the server and than return a video_path to the client. The client could than send a POST to this url and thus upload the video.

Could this be achieved with yt?

Make :data an attr_reader when possible

For objects like Snippet or StatisticsSet, might be useful (to @Nuru) to get access to the raw data returned by YouTube, which is already present in the @data instance variable, but needs to be made public.

Collection mutability issues

Unintuitive behavior when attempting to insert a model while iterating through (a separate) collection of that same model.

See the following:

content_owner = Yt::ContentOwner.new '...'
inactive_claims = content_owner.claims.where(asset_id: "A243581141664493", status: "inactive")

inactive_claims.each do |inactive_claim|
  content_owner.create_claim({})
end

Even if inactive_claims.size == 100, this will only insert one claim.

Upon the first call of create_claim, the existing collection (which we're iterating through) is zeroed out and the iteration will terminate.

https://github.com/Fullscreen/yt/blob/master/lib/yt/actions/insert.rb#L14

I feel there should be a way to return an immutable collection when calling .where, rather than continuously mutating the same item collection which leads to difficult to debug scenarios like this above.

While authenticated, can't hit /youtube/v3/videos end point

I'm trying to get all public videos from a channel, then do a /videos call to retrive them and the statistics all at once (since the /search endpoint doesn't support part statistics).

The following doesn't work though, since it always hits /youtube/v3/search...

account = Yt::Account.new(....) # properly authenticated
_videos1 = account.channel.videos
puts _videos1.count => 736

ids = _videos1.map(&:id)
_videos2 = ids.in_groups_of(50, false).flat_map { |_ids|
  account.channel.videos.where(
    :id => _ids.join(","),
    :part => "snippet,statistics"
  ).flat_map { |v| v }
}

=> {"error":{"errors":[{"domain":"youtube.part","reason":"unknownPart","message":"statistics","locationType":"parameter","location":"part"}],"code":400,"message":"statistics"}}

collections/video.rb#use_list_endpoint looks like it'll only work when doing public requests, since parent is always set if you go through account.channel.videos...

Any ideas how I can achieve this?

channel.videos is missing a couple results

Hi, I have a channel with 30 public videos, but only 28 are returned via:

channel = Yt::Channel.new id: 'UCu6xSm33KXu8F2vo7UkzYsQ'
videos = channel.videos.includes(:statistics)

Thoughts? I assume this is a problem with the YouTube API as opposed to yt, but thought I'd ask here first.

Implement support for large video file uploads without massive memory consumption

As per comment on: 2d68bdb

Looks like the current implementation reads the whole file into memory, then sends to YouTube. This will be crippling for video files several GB in size.

youtube_it handles this nicely by downloading and saving a chunk of the file at a time, then on upload, sending a chunk of the file at a time. See these two files for inspiration:

Downloading: https://github.com/kylejginavan/youtube_it/blob/master/lib/youtube_it/request/remote_file.rb
Uploading: https://github.com/kylejginavan/youtube_it/blob/master/lib/youtube_it/chain_io.rb

scopes not passing as parameter

tried just doing the very basic thing of initializing an account, with this: (i have @redirect_uri stored in my controller)

Yt::Account.new(scopes: 'https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile' , redirect_uri: @redirect_uri).authentication_url

and the response i get was:

Error: invalid_request

Missing required parameter: scope

Request Details
scope=
response_type=code
redirect_uri=http://localhost:3000/youtube/connected <- my redirect_uri is getting passed
access_type=offline
approval_prompt=auto
client_id=820356551033-8iaf7ljkf86m92d3tu202b3b67g4eeg6.apps.googleuserco

Missing video attributes that youtube_it provides

youtube_it user here, looking to possibly migrate since it looks as if they won't be supporting the v3 API.

However, I'm missing some major things on the 'video' resource, such as:

  • embed_html_with_width (returns html embed code)
  • player_url (returns URL of video)

I'm poking around the video model and don't see a way to access any of this. A little help? Thanks!

Don’t store `.where` conditions when `.where` is not used

If you get a list with a where condition first:

channel.videos.where(q: 'anything').count

and then try to get the same list without any where condition:

channel.videos.count

you still get the first video count, because the cached list is returned.
This only happens if the second call does not have any where condition.
If a different condition is specified, it does not happen.

Missing closing </iframe> tag calling embed_html on video

video = Yt::Video.new id: 'BPNYv0vd78A'
video.embed_html

<iframe type='text/html' src='http://www.youtube.com/embed/BPNYv0vd78A' width='640' height='360' frameborder='0' allowfullscreen='true'/>

I don't know if this behaviour depends on your gem.

Creating Assets ignores metadata_mine parameter

web assets (and others) require a title to be created, which Yt currently doesn't support.

This should a valid payload for Yt:

{
  "type" : "web",
  "metadataMine" : {
     "title" : "Title goes here"
  }
}

Translating to Yt:

content_owner.create_asset type: "web", metadata_mine: { title: "Title goes here" }

Currently all params being sent to assets#insert are ignored other than type.

See: https://github.com/Fullscreen/yt/blob/master/lib/yt/collections/assets.rb#L12-L15

(This is mostly a reminder for myself to fix it)

Yt::Errors::ServerError: A request to YouTube API caused an unexpected server error:

I can get result return from google now, but it does not display properly.

  require 'yt'
  Yt.configure do |config|
    config.api_key = 'my key'
    config.log_level = :debug
  end

  video = Yt::Video.new(id: 'MESycYJytkU')

It returns

      Yt::Errors::ServerError: A request to YouTube API caused an unexpected server er
      ror:
          {}

      You can retry the same request manually by running:
                                                     curl -X GET -H "content-length: 0" -H "user-agent: Yt::Request (gzip)" "https://
    www.googleapis.com/youtube/v3/videos?id=MESycYJytkU&key=****&part=snippet"


      D:in `each'
    D:in `each'
    D:in `first'
      D:in `first'
    D:in `title'

I checked the link, it is the info about the video. But it can't return it in proper form. Why is that?

Plan to release 1.0

As this project turns one year, and as YouTube is deprecating V2, it’s time to make some decisions about the API of Yt and clarify which objects and methods are available.

I feel pretty confident about the current classes and methods of Yt. I don't intend to replace something as simple as: video = Yt::Video.new id: 'video_id'; video.title with anything else. I just want to make sure that every public method is documented, before I can say this is version 1.0 of Yt.

So far, I have fully documented two classes. Here are the API documentation and usage guide for Yt::Video, and here are the API documentation and usage guide for Yt:Channel.

In the next days I'll be working on the remaining classes. If you have any feedback on methods that should be deprecated or that should have a different signature, this is the right time to reach out.

To clarify, v1.0 does not mean that new features won't be added. It just guarantees that all the public classes and methods available in v1.0 won't get changed until v2.0.

If you scroll through the CHANGELOG you can get an idea of methods that have been in Yt at some moments and won't be part of 1.0.

Thanks for your support and feedback! @stavro @KieranP @subimage @tomfbiz @lukevmorris @matuag @claudeomusic @zerogee00 @NARKOZ @nickcoyne @bodrovis @raptblue @thebravoman @KevinVerre @hakunin @Grafikart @catchouli @sbounmy @datnt @kxcrl @dustinleblanc @jdwolk @timzero @pwnall

Is there a way to set maxResults for channel.videos response?

Some channels return hundreds of videos. It would be nice to be able to set the maxResults parameter for a channel's videos response.

I tried looking at the code and docs, but I'm not seeing a way to set maxResults. If anything, it looks like maxResults might default to 50, but hasn't been the case for me.

Unless it's already implemented, I'd be happy to try and implement a method of passing the max_results as an option, unless there's some reason it's not supported.

Deprecate `owner_name`

We should remove the references for owner_name (but leave backwards compatibility in the initializers and attribute name) and instead use the term id throughout yt.

Related: This also begs the question of removing the ContentOwner < Account inheritance, since they are logically two separate entities on YouTube's end (In reality, a single account can have many content owners). Perhaps some useful delegation and relationship models can make this more seamless. But making the above change brings up an area of contention when calling content_owner.id, since the underlying account id would no longer be accessible.

image

SystemStackError: stack level too deep on to_json

Hi i'm getting this error when I try to convert the response from Yt::Channel to json.

Yt.configure do |config|
  config.api_key = "mykey"
end

chann = Yt::Channel.new id: "UCWI70VlhoBiCvhmDMQle9UA"
chann.to_json

Show this output:

SystemStackError: stack level too deep
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/instance_variables.rb:13:in instance_values' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:50:inas_json'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in block in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:ineach'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in map' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:inas_json'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:50:in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:inblock in as_json'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in each' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:inmap'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:50:inas_json'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in block in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:ineach'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in map' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:inas_json'
... 7851 levels...
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in block in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:ineach'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:in map' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:159:inas_json'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:50:in as_json' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/json/encoding.rb:34:inencode'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/json/encoding.rb:21:in encode' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:37:into_json_with_active_support_encoder'
from (irb):66
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in start' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/railties-4.2.0/lib/rails/commands/console.rb:9:instart'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in console' from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /home/mbeach/.rvm/gems/ruby-2.2.0@merge6/gems/railties-4.2.0/lib/rails/commands.rb:17:in <top (required)>' from bin/rails:4:inrequire'

What should I do to get the json correctly ?

How to authorize for offline access?

I'm building my URL using the following code:

Yt::Account.new(scopes: ['userinfo.email', 'youtube.readonly'], redirect_uri: new_channel_url).authentication_url

Then I use the code like so:

yt = Yt::Account.new authorization_code: params[:code], redirect_uri: new_channel_url

When accessing yt.authentication.refresh_token I get nil. Since the default behavior of the gem requests offline access, shouldn't I be getting a refresh token?

Upload video

Hi claudiofullscreen,

How to upload video by using this library?

How to rescue YT::Errors

I'm getting an error, how do I rescue the error or at least access the exact error message. I am having issues uploading thumbnails and I can't narrow down why it's not working.

Thanks

.where conditions should not be cached on subsequent requests

The @extra_params parameter that populates the .where conditions should be cleaned up after each request, otherwise the following happens:

account.videos.where(q: 'x').count
# invokes "https://www.googleapis.com/youtube/v3/search?forMine=true&maxResults=50&order=date&part=snippet&q=x&type=video"

account.videos.count
# invokes "https://www.googleapis.com/youtube/v3/search?forMine=true&maxResults=50&order=date&part=snippet&q=x&type=video"

The second request should not keep the previous q: 'x'.
This is a bug on master and the reason why tests are currently failing.

Search is way too slow

I have flowing code...
client = Yt::Collections::Videos.new
videos = client.where(q: keyword, safe_search: 'none',order: 'viewCount',maxResults: 20)

When processing videos i end up to process all results which is too slow (because of so many results) so how can i limit it to n records only?

Feature Request: Location Latitude & Longitude

Maybe I missed it, but would love to be able to read, and upload with latitude and longitude.

Google API:
recordingDetails.location object - The geolocation information associated with the video.
recordingDetails.location.latitude - double - Latitude in degrees.
recordingDetails.location.longitude - double - Longitude in degrees.

Get comments

Comments can only be accessed by authenticated users

y = Yt::Video.new id: 'RC5DqWXZbRg'
y.comments
NoMethodError: undefined method owner_name' for nil:NilClass from gems/yt-0.22.0/lib/yt/models/video.rb:572:inblock in reports_params'

But looking at Youtube documentation, comments should be publicly accessible ie:
https://www.googleapis.com/youtube/v3/commentThreads?part=id,snippet,replies&textFormat=plainText&maxResults=100&videoId=U55NGD9Jm7M&key=

Documentation https://developers.google.com/youtube/v3/docs/commentThreads

Can we make an update to the gem? I can help

[Add documentation about] Can only create playlists for default 'channel'

I'm giving playlists a full workout here...

I know that you can call yt_account.create_playlist and it will be created on the default channel. I also know that we can access all the channels that belong to an account.

My question is, why can't we create playlists for other channels that belong to the account?

Also, I believe the documentation here needs some work: http://fullscreen.github.io/yt/playlists.html

Specifically, I go there looking to figure out how to create_playlist, but of course it's over in Account

uninitialized constant OpenSSL::SSL::SSLErrorWaitReadable

Hello and thanks for the great gem.

Using the latest version I get an error uninitialized constant OpenSSL::SSL::SSLErrorWaitReadable. Error trace:

        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:205:in
 `server_errors'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:242:in
 `response_error'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:256:in
 `unauthorized?'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:230:in
 `refresh_token_and_retry?'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:198:in
 `run_again?'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/request.rb:81:in
`run'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/actions/list.rb:9
5:in `fetch_page'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/actions/list.rb:8
5:in `next_page'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/actions/list.rb:5
0:in `find_next'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/actions/list.rb:2
1:in `block in list'
        from F:in `each'
        from F:in `each'
        from F:in `first'
        from F:in `first'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/actions/list.rb:1
3:in `first!'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/associations/has_
one.rb:17:in `block in has_one'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/associations/has_
attribute.rb:45:in `instance_eval'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/yt-0.13.7/lib/yt/associations/has_
attribute.rb:45:in `block in define_memoized_method'
        from F:in `title'
        from (irb):18
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/
console.rb:90:in `start'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/
console.rb:9:in `start'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/
commands_tasks.rb:69:in `console'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/
commands_tasks.rb:40:in `run_command!'
        from F:/Ruby/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands.
rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

This can be reproduced by creating a video resource like

v = Yt::Video.new url: 'https://www.youtube.com/watch?v=lE3a5-Kep3Y'

and issuing

v.title

or similar method (like comment_count).

SyntaxError in version 0.14.1

Error message:

SyntaxError: /Users/gautam/.rvm/gems/jruby-1.7.19/gems/yt-0.14.1/lib/yt/collections/reports.rb:6: syntax error, unexpected tLPAREN_ARG
      DIMENSIONS = Hash.new({name: 'day', parse: -> (day) {Date.iso8601 day} }).tap do |hash|
                                                    ^

yt gem version: 0.14.1

Ruby version:
jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on Java HotSpot(TM) 64-Bit Server VM 1.8.0_25-b17 +jit [darwin-x86_64]

How do I authenticate Yt::Playlist?

  • I have a playlist ID. It corresponds to a user's playlist of Liked Videos.
  • However, when I try to get that Playlist by calling Yt::Playlist.new(id: liked_id), YT says that it did not return any values.
  • It shows the URL it is using. Indeed when I put that URL in my browser I don't get any values. I'm getting a Forbidden response.
  • But I add &access_token=theAccessTokenString to the URL in my browser I DO get the playlist items in my browser
  • So I am not authenticating correctly when I call Yt::Playlist.new(id: liked_id).playlist_items
  • I know that I can correctly authenticate using the Yt gem when I am asking for an Account or Channel object. I don't know how to do it with a Playlist.
  • I tried Yt::Playlist.new(id: liked_id, access_token: token_string).playlist_items but that didn't work either.
  • Please advise.
  • Some background: If you want to show a user his created playlists you can use Yt::Account.new(access_token: token_string).channel.playlists. However, this does not include the Special Playlists that YouTube has for each User. (liked videos, history of videos watched, uploaded videos, etc.) I couldn't find documentation of how to get these Special Playlists with the Yt Gem. So instead I got the ID for the liked videos playlist querying the YouTube v3 api directly and parsing the response. Now I'm trying to figure out how to use that ID and an authenticated user to get back the playlist.
  • The URL I got the id from was something like this: "https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=#{youtube_username_escaped}&key=#{api_key}&access_token=#{access_token}"
  • I might just query YouTube directly again, but it would be simpler if I could use the Gem to do it for me.

Yt::Collections::Videos sort parameter does not work

I was having problems with youtube's recent search (Youtube bug makes it return the same items more than once and does not return other matches), so I tried to set the sort back to the default of relevance with the following code

v=videos.where(q: 'Freudenheim', safe_search: 'none',sort:'relevance').first(10)

but I get the exact same results as without the sort parameter. Using google's api test page, the parameter works in their api.

Cannot page through Video results when not requesting 'snippet'

There are some bugs in iterating through Video results. This code:

    Yt::Collections::Videos.new.where(id: yt_ids.join(','), part: 'statistics').each do |yt_video|

generates this error:

undefined method `[]' for nil:NilClass
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/collections/videos.rb:46:in `add_offset_to'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/collections/videos.rb:37:in `block in next_page'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/collections/videos.rb:37:in `tap'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/collections/videos.rb:37:in `next_page'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/actions/list.rb:50:in `find_next'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/actions/list.rb:21:in `block in list'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/actions/list.rb:9:in `each'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/actions/list.rb:9:in `each'
/Users/user/.rvm/gems/ruby-2.1.2@jazz/gems/yt-0.13.0/lib/yt/actions/list.rb:9:in `each'

Looks to me like the implementations of Videos#next_page and Videos#add_offset_to are only appropriate when using the "search" endpoint and the code above uses the "videos" endpoint. If the above code also requested "snippet" then the code would probably still fail, just in a different way.

Performance when requesting additional attributes from search results

Due to the limited fields that are returned in search results, yt has to make additional api requests to get some additional fields (specifically we also want duration and view_count). When iterating through a set of search results to do this the performance is poor.

See https://code.google.com/p/gdata-issues/issues/detail?id=4294

Google's suggested workaround is to bundle the additional requests for all search results into a single additional api call. However I don't see a way to do this currently with yt?

Channel.videos limited to 500

When accessing the videos of a channel with more than 500 videos, Channel.videos seems to be limited to 500 results. For example, for the channel raocow (channel = Yt::Channel.new url: 'http://www.youtube.com/raocow') channel.videos.count == 500 but channel.video_count == 3500 or so.

Googling makes it seem like this might be an API limit? I believe that youtube_it gets all videos for a channel by setting a start index and iterating until all videos are obtained. Is it possible to do such a thing with this library? Otherwise, would it be possible for this to be supported?

I considered writing such a thing myself but I was unsure where it fit in with the architecture of the library.

Thanks for the great software,
Cat

Batch video lookup

Thanks for this software. I'm using 0.24.0.

I'm trying to look up a list of videos and display them on a page, but recently it got very slow. I installed rack-mini-profiler to check what was going on. Here's my code:

videoData = Yt::Collections::Videos.new.where(id: "UL6PN8qVtVU,iCWhr6ANr7U,kOUv7jL4dhc,WNKp8E-Hqg0,YmFPrfDvXL8,UycF9NrvWyE,Awm4C1ghW4s,6fC4E7mm5z4")

@recent = videoData.map { |v| { video_id: v.id,
                                title: v.title,
                                views: v.view_count,
                                duration: v.duration } }

The problem is that it not only seems to do one look up per video, but multiple. Here's the output of rack-mini-profiler: https://dl.dropboxusercontent.com/u/95554481/pictures/yt.PNG

Apologies if it's my sample that's the problem.

Cat

Support onBehalfOfContentOwner and onBehalfOfContentOwnerChannel on Videos: insert

I've authenticated as a content owner who owns and manages multiple channels. I want to upload a video to one of those channels instead of the content owner's own channel (if one exists)

https://developers.google.com/youtube/v3/docs/videos/insert

I'd like to be able to:

upload_video(path_or_url, params = {}, content_owner_params = {})

where content_owner_params hash contains the Content Owner id and the Channel id

Thanks!

Yt::Collections::Videos returns same video more than once

For instance when I do the following query:

    items = Yt::Collections::Videos.new.where(q:"greens of london", safe_search: 'strict',embeddable: true)

items.count returns 199
...but if I do items.first(80)
i[0].id==i[22].id and i[37].id and i[52] and i[74]

and similarly i[1]==[i[23] and 38,53,75

But if I change the search term to "Justin" I get all unique results.

If I search for "Freudenheim" I get 4 results, but the first is the same as the third and the 2nd is the same as the 4th.

Is there a way to automatically eager-load a video on initialization?

When a user provides a url to a Youtube video, I'd like to know immediately whether or not that url points to a valid id. As of right now, the gem will accept any url in the initialization phase, and create a video instance:

video = Yt::Video.new(url: "www.facebook.com")
=> #<Yt::Models::Video:0x007fe01dd56240 ...>

It's only when I attempt to access data on that video later that an error is thrown:

video.title
=> NameError: uninitialized constant OpenSSL::SSL::SSLErrorWaitReadable

Or, for youtube urls with an invalid id:

video = Yt::Video.new(url: "https://www.youtube.com/watch?v=l_JMrETiwQV")
=> #<Yt::Models::Video:0x007fe0168a6530 ...>
video.title
=> Yt::Errors::NoItems: ...

Is there any way to configure the gem such that the resource be eager-loaded by default? Here's what I'm doing for the time being to get around the issue:

video = Yt::Video.new(url: "https://www.youtube.com/watch?v=l_JMrETiwQV").tap(&:title)
=> Yt::Errors::NoItems: ...

Thanks!

'options must be a hash' error on account

Hi,

I am trying to migrate an app using youtube_it to Yt. I have the following code

 def configure_youtube(access_token, refresh_token)
        Yt.configure do |config|
          config.client_id = ENV["google_client_id"]
          config.client_secret = ENV["google_client_secret"]
        end
      client =  Yt::Account.new access_token: access_token, refresh_token: refresh_token
      email = client.email
 end

When I call client.email or any account attribute (id, name, etc) I get the error 'options must be a hash'. Full stack trace here: https://gist.github.com/ermacaz/662b6345a69a4e274dd1

If I call client.videos I get back an instance of Yt::Collections::Videos, but calling anything like client.videos.first also returns 'options must be a hash'.

Any help is appreciated

Yt.configure threadsafety

First of all, thank you for this great gem supporting youtube api v3.

AFAIK, Yt.configure is not threadsafe because it is an instance "module" variable.
This is not urgent, I would appreciate your feedback on this, I will probably do a pull request later once we decide to replace youtube_it by yt in our app

Cheers,
Stephane.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.