Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️ Fix specs and update deps #211

Merged
merged 12 commits into from
Feb 23, 2023
Merged
7 changes: 4 additions & 3 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Ruby Unit Tests

on: [push, pull_request]

env:
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
VIMEO_ACCESS_TOKEN: ${{ secrets.VIMEO_ACCESS_TOKEN }}

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -13,9 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
env:
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
VIMEO_ACCESS_TOKEN: ${{ secrets.VIMEO_ACCESS_TOKEN }}
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
Expand Down
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Contributing
--------
# Contributing

The guidelines for contributions are as follows:
* Make sure you include comprehensive specs for new features and bug-fixes

* Make sure you include comprehensive specs for new features and bug-fixes.
* Make sure all of the specs pass by running `rspec` in the root project directory. Pull requests with failing tests will not be merged.
* Make sure there are no style issues by running `rubocop` in the root project directory. Pull requests with style issues will not be merged
* Make sure there are no style issues by running `rubocop` in the root project directory. Pull requests with style issues will not be merged.
* Optimally, you should create a separate branch to make rebasing with `master` simpler if other work gets merged in before your patch does.
* In bug reports, post the outputs of `VideoInfo::VERSION` and `ruby --version`
* In bug reports, post the outputs of `VideoInfo::VERSION` and `ruby --version`.
* In bug reports, provide detailed and clear reproduction steps. Optimally, provide some sample code.
* In bug reports, try to test against the `master` branch. If the bug does not exist in `master`, it is most likely known and a fix will be in the next release.
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
source 'http://rubygems.org'

# Specify your gem's dependencies in video_info.gemspec
gemspec

gem 'coveralls', require: false

group :tool do
gem 'ruby_gntp'
gem 'guard-rspec'
end
8 changes: 0 additions & 8 deletions Guardfile

This file was deleted.

43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@

Simple Ruby Gem to get video info from Dailymotion, Vimeo, Wistia and YouTube (with playlist).

Tested against Ruby 2.5.x, 2.6.x and 2.7.x.
Tested against Ruby 2.6, 2.7, 3.0, 3.1 and 3.2.

## Features

Features
--------
* Simple, single-function API that returns a simple data structure
* Has a mere three gem dependencies
* Automatic fallback to scrapers when required API keys aren't provided
* Fetches metadata on the video, including title, duration, upload date, description, keywords, thumbnail, and dimensions
* Fetches metadata on the author, including name, thumbnail, and channel/profile URL

Install
--------
## Install

``` bash
```bash
gem install video_info
```

Usage
-----
## Usage

### Note for YouTube and Vimeo usage!

Expand All @@ -37,12 +35,14 @@ After generating a Youtube API key it is necessary to enable the YouTube Data AP
To get a Vimeo API key, [follow the instructions here](https://developer.vimeo.com/api/start)

To set the API keys, do the following:
``` ruby

```ruby
VideoInfo.provider_api_keys = { youtube: 'YOUR_YOUTUBE_API_KEY', vimeo: 'YOUR_VIMEO_API_KEY' }
```

### Basic Usage

``` ruby
```ruby
video = VideoInfo.new('http://www.dailymotion.com/video/x7lni3')
# video.available? => true
# video.video_id => 'x7lni3'
Expand Down Expand Up @@ -135,18 +135,18 @@ You can also use the `valid_url?` helper to check if a given url is valid in som
=> false
```

Options
-------
### Options

``` ruby
```ruby
video = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'User-Agent' => 'My YouTube Mashup Robot/1.0')
video = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'Referer' => 'http://my-youtube-mashup.com/')
video = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'Referer' => 'http://my-youtube-mashup.com/',
'User-Agent' => 'My YouTube Mashup Robot/1.0')
```

You can also use **symbols** instead of strings (any non-word (`/[^a-z]/i`) character would be converted to hyphen).

``` ruby
```ruby
video = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', referer: 'http://my-youtube-mashup.com/',
user_agent: 'My YouTube Mashup Robot/1.0')
```
Expand All @@ -157,7 +157,7 @@ It supports all openURI header fields (options), for more information see: [open

You can also include an `iframe_attributes` or `url_attributes` hash to the `embed_code` method to include arbitrary attributes in the iframe embed code or as additional URL params:

``` ruby
```ruby
VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4').embed_code(iframe_attributes: { width: 800, height: 600, 'data-key' => 'value' })
=> '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen" width="800" height="600" data-key="value"></iframe>'

Expand All @@ -167,29 +167,24 @@ VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4').embed_code(url_attri

If you would like to disable certain providers, you can do so by modifying the class variable `disable_providers`:

``` ruby
```ruby
VideoInfo.disable_providers = %w[YouTube] # disable YouTube
VideoInfo.disable_providers = %w[Vimeo YouTube] # disable Vimeo and Youtube
VideoInfo.disable_providers = [] # enable all providers
```

Note: `disable_providers` is case-insensitive. Attempting to use a disabled provider will raise a UrlError, just like attempting to use a
non-video URL.


Author
------
## Author

[Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))

Maintainers
-----------
## Maintainers

- [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))
- [Vincent Heuken](https://github.com/vheuken) ([@vheuken](https://github.com/vheuken))
- [JoĂŁo Vieira](https://github.com/joaocv3) ([@joaocv3](https://github.com/joaocv3))

Contributors
------------
## Contributors

[https://github.com/thibaudgg/video_info/graphs/contributors](https://github.com/thibaudgg/video_info/graphs/contributors)
2 changes: 1 addition & 1 deletion lib/video_info/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def data
end

def available?
!%w[403 404 400].include?(_response_code)
!%w[403 404 400 451 401].include?(_response_code)
end

def thumbnail
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading