{"id":13463428,"url":"https://github.com/thibaudgg/video_info","last_synced_at":"2025-05-15T05:05:22.125Z","repository":{"id":457698,"uuid":"81634","full_name":"thibaudgg/video_info","owner":"thibaudgg","description":"Get video info from Dailymotion, Vimeo, Wistia, and YouTube URLs.","archived":false,"fork":false,"pushed_at":"2024-03-18T09:22:32.000Z","size":85581,"stargazers_count":432,"open_issues_count":4,"forks_count":132,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-15T05:05:08.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/video_info","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thibaudgg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2008-11-27T09:04:58.000Z","updated_at":"2025-05-13T04:16:18.000Z","dependencies_parsed_at":"2023-07-05T15:01:31.685Z","dependency_job_id":"62dd16ed-1712-45d7-a131-e2b76d7cdcb3","html_url":"https://github.com/thibaudgg/video_info","commit_stats":{"total_commits":761,"total_committers":46,"mean_commits":"16.543478260869566","dds":0.5492772667542707,"last_synced_commit":"5d17698a1d42619d2b887b87a9013097fd2cdfce"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thibaudgg%2Fvideo_info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thibaudgg%2Fvideo_info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thibaudgg%2Fvideo_info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thibaudgg%2Fvideo_info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thibaudgg","download_url":"https://codeload.github.com/thibaudgg/video_info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276446,"owners_count":22043866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:53.282Z","updated_at":"2025-05-15T05:05:22.098Z","avatar_url":"https://github.com/thibaudgg.png","language":"Ruby","funding_links":[],"categories":["Web Apps, Services \u0026 Interaction","Ruby","Video"],"sub_categories":["API Clients"],"readme":"# VideoInfo\n\n[![Gem Version](https://badge.fury.io/rb/video_info.svg)](http://badge.fury.io/rb/video_info)\n[![CI](https://github.com/thibaudgg/video_info/actions/workflows/ci.yml/badge.svg)](https://github.com/thibaudgg/video_info/actions/workflows/ci.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/1f03474bdb81e735002c/maintainability)](https://codeclimate.com/github/thibaudgg/video_info/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/1f03474bdb81e735002c/test_coverage)](https://codeclimate.com/github/thibaudgg/video_info/test_coverage)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)\n\nSimple Ruby Gem to get video information from different providers. Supported providers:\n\n- YouTube (with playlists)\n- Vimeo\n- Dailymotion\n- Wistia\n\n## Features\n\n* Simple, single-function API that returns a simple data structure\n* Has a mere three gem dependencies\n* Automatic fallback to scrapers when required API keys aren't provided\n* Fetches metadata on the video, including title, duration, upload date, description, keywords, thumbnail, and dimensions\n* Fetches metadata on the author, including name, thumbnail, and channel/profile URL\n\n## Install\n\n```bash\ngem install video_info\n```\n\nOr add to the Gemfile:\n\n```bash\ngem 'video_info'\n```\n\n## Usage\n\n### Note for YouTube and Vimeo usage!\n\nYoutube and Vimeo have recently updated their APIs to require API keys.\n\nScrapers has been implemented for both Youtube and Vimeo. However, the Youtube scraper can only get the date the video was posted, while the API is able to get the date and the exact time the video was posted. You may also wish to use the API to protect against potential HTML changes that could break the scrapers.\n\n**How to get these API keys**\n\n- To get a Youtube API key, [follow the instructions here](https://developers.google.com/youtube/registering_an_application). After generating a Youtube API key it is necessary to enable the YouTube Data API for the project which your API key was generated [enable Youtube Data API here](https://console.developers.google.com/apis/library/youtube.googleapis.com).\n- To get a Vimeo API key, [follow the instructions here](https://developer.vimeo.com/api/start).\n\nTo set the API keys, do the following:\n\n```ruby\nVideoInfo.provider_api_keys = { youtube: 'YOUR_YOUTUBE_API_KEY', vimeo: 'YOUR_VIMEO_API_KEY' }\n```\n\n### Basic Usage\n\n```ruby\nvideo = VideoInfo.new('http://www.dailymotion.com/video/x7lni3')\n# video.available?       =\u003e true\n# video.video_id         =\u003e 'x7lni3'\n# video.provider         =\u003e 'Dailymotion'\n# video.title            =\u003e 'Mario Kart (Rémi Gaillard)'\n# video.description      =\u003e 'Super Rémi Kart est un jeu vidéo de course développé et édité par N'Importe Quoi TV.'\n# video.duration         =\u003e 136 (in seconds)\n# video.date             =\u003e Mon Mar 03 16:29:31 UTC 2008\n# video.thumbnail_small  =\u003e 'http://s2.dmcdn.net/BgWxI/x60-kbf.jpg'\n# video.thumbnail_medium =\u003e 'http://s2.dmcdn.net/BgWxI/x240-b83.jpg'\n# video.thumbnail_large  =\u003e 'http://s2.dmcdn.net/BgWxI/x720-YcV.jpg'\n# video.embed_url        =\u003e 'http://www.dailymotion.com/embed/video/x7lni3'\n# video.embed_code       =\u003e \"\u003ciframe src='//www.dailymotion.com/embed/video/x7lni3' frameborder='0' allowfullscreen='allowfullscreen'\u003e\u003c/iframe\u003e\"\n# video.stats            =\u003e {\"views_total\"=\u003e10342797, \"likes_total\"=\u003e3850}\n\nvideo = VideoInfo.new(\"http://vimeo.com/898029\")\n# video.available?       =\u003e true\n# video.video_id         =\u003e '898029'\n# video.provider         =\u003e 'Vimeo'\n# video.title            =\u003e 'Cherry Bloom - King Of The Knife'\n# video.description      =\u003e 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net'\n# video.author           =\u003e 'Octave Zangs'\n# video.author_thumbnail =\u003e 'https://i.vimeocdn.com/portrait/2577152_75x75.jpg'\n# video.author_url       =\u003e 'https://vimeo.com/octave'\n# video.keywords         =\u003e 'alternative, bloom, cherry, clip, drum, guitar, king, knife, of, Paris-Forum, rock, the, tremplin'\n# video.duration         =\u003e 175 (in seconds)\n# video.date             =\u003e Mon Apr 14 13:10:39 +0200 2008\n# video.width            =\u003e 640\n# video.height           =\u003e 360\n# video.thumbnail_small  =\u003e 'http://b.vimeocdn.com/ts/343/731/34373130_100.jpg'\n# video.thumbnail_medium =\u003e 'http://b.vimeocdn.com/ts/343/731/34373130_200.jpg'\n# video.thumbnail_large  =\u003e 'http://b.vimeocdn.com/ts/343/731/34373130_640.jpg'\n# video.embed_url        =\u003e 'http://player.vimeo.com/video/898029'\n# video.embed_code       =\u003e \"\u003ciframe src='//player.vimeo.com/video/898029?title=0\u0026amp;byline=0\u0026amp;portrait=0\u0026amp;autoplay=0' frameborder='0'\u003e\u003c/iframe\u003e\"\n# video.stats            =\u003e {\"plays\"=\u003e630, \"likes\"=\u003e3, \"comments\"=\u003e0}\n\nvideo = VideoInfo.new(\"http://fast.wistia.com/embed/medias/pxonqr42is\")\n# video.available?       =\u003e true\n# video.provider         =\u003e 'Wistia'\n# video.video_id         =\u003e 'pxonqr42is'\n# video.title            =\u003e 'Understanding Analytics'\n# video.duration         =\u003e 250 (in seconds)\n# video.width            =\u003e 960\n# video.height           =\u003e 568\n# video.thumbnail_small  =\u003e 'https://embed-ssl.wistia.com/deliveries/0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg?image_crop_resized=960x540'\n# video.thumbnail_medium =\u003e 'https://embed-ssl.wistia.com/deliveries/0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg?image_crop_resized=960x540'\n# video.thumbnail_large  =\u003e 'https://embed-ssl.wistia.com/deliveries/0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg?image_crop_resized=960x540'\n# video.embed_url        =\u003e '//fast.wistia.net/embed/iframe/pxonqr42is'\n# video.embed_code       =\u003e \"\u003ciframe src='//fast.wistia.net/embed/iframe/pxonqr42is' frameborder='0'\u003e\u003c/iframe\u003e\"\n\nvideo = VideoInfo.new(\"http://www.youtube.com/watch?v=mZqGqE0D0n4\")\n# video.available?       =\u003e true\n# video.video_id         =\u003e 'mZqGqE0D0n4'\n# video.provider         =\u003e 'YouTube'\n# video.title            =\u003e 'Cherry Bloom - King Of The Knife'\n# video.author           =\u003e 'Cherry Bloom'\n# video.author_thumbnail =\u003e 'https://yt3.ggpht.com/-7rhnfdQaI3k/AAAAAAAAAAI/AAAAAAAAAAA/eMJZ5HBukCQ/s88-c-k-no/photo.jpg'\n# video.author_url       =\u003e 'https://www.youtube.com/channel/UCzxQk-rZGowoqMBKxGD5jSA'\n# video.description      =\u003e 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net'\n# video.duration         =\u003e 175 (in seconds)\n# video.date             =\u003e Sat Apr 12 22:25:35 UTC 2008\n# video.thumbnail_small  =\u003e 'http://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg'\n# video.thumbnail_medium =\u003e 'http://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg'\n# video.thumbnail_large  =\u003e 'http://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg'\n# video.embed_url        =\u003e 'http://www.youtube.com/embed/mZqGqE0D0n4'\n# video.embed_code       =\u003e \"\u003ciframe src='//www.youtube.com/embed/mZqGqE0D0n4' frameborder='0' allowfullscreen='allowfullscreen'\u003e\u003c/iframe\u003e\"\n# video.stats            =\u003e {\"viewCount\"=\u003e\"8297\", \"likeCount\"=\u003e\"66\", \"favoriteCount\"=\u003e\"0\", \"commentCount\"=\u003e\"5\"}\n\nplaylist = VideoInfo.new(\"http://www.youtube.com/playlist?p=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr\")\n# playlist.available?          =\u003e true\n# playlist.playlist_id         =\u003e 'PL9hW1uS6HUftLdHI6RIsaf'\n# playlist.provider            =\u003e 'YouTube'\n# playlist.title               =\u003e 'YouTube Policy and Copyright'\n# playlist.author              =\u003e 'YouTube Help'\n# playlist.author_thumbnail    =\u003e 'https://yt3.ggpht.com/-ni_VaN38-AE/AAAAAAAAAAI/AAAAAAAAAAA/bJCTTfihBl0/s100-c-k-no/photo.jpg'\n# playlist.author_url          =\u003e 'https://www.youtube.com/user/YouTubeHelp'\n# playlist.thumbnail_small     =\u003e 'http://i.ytimg.com/vi/8b0aEoxqqC0/default.jpg'\n# playlist.thumbnail_medium    =\u003e 'http://i.ytimg.com/vi/8b0aEoxqqC0/mqdefault.jpg'\n# playlist.thumbnail_large     =\u003e 'http://i.ytimg.com/vi/8b0aEoxqqC0/hqdefault.jpg'\n# playlist.embed_url           =\u003e 'http://www.youtube.com/embed/videoseries?list=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr'\n# playlist.embed_code          =\u003e \"\u003ciframe src='//www.youtube.com/embed/videoseries?list=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr' frameborder='0' allowfullscreen='allowfullscreen'\u003e\u003c/iframe\u003e\"\n# playlist.videos              =\u003e [VideoInfo.new('http://www.youtube.com/watch?v=_Bt3-WsHfB0'), VideoInfo.new('http://www.youtube.com/watch?v=9g2U12SsRns'), VideoInfo.new('http://www.youtube.com/watch?v=8b0aEoxqqC0'), VideoInfo.new('http://www.youtube.com/watch?v=6c3mHikRz0I'), VideoInfo.new('http://www.youtube.com/watch?v=OQVHWsTHcoc')]\n```\n\nYou can also use the `valid_url?` helper to check if a given url is valid in some of the _enabled_ providers:\n\n```ruby\n\u003e VideoInfo.valid_url?('http://www.youtube.com/watch?v=AT_5xOGh6Ko')\n=\u003e true\n\u003e VideoInfo.valid_url?('http://vimeo.com/898029')\n=\u003e true\n\u003e VideoInfo.valid_url?('http://www.example.com/video/12345')\n=\u003e false\n```\n\n### Options\n\n```ruby\nvideo = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'User-Agent' =\u003e 'My YouTube Mashup Robot/1.0')\nvideo = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'Referer'    =\u003e 'http://my-youtube-mashup.com/')\nvideo = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', 'Referer'    =\u003e 'http://my-youtube-mashup.com/',\n                                                                    'User-Agent' =\u003e 'My YouTube Mashup Robot/1.0')\n```\n\nYou can also use **symbols** instead of strings (any non-word (`/[^a-z]/i`) character would be converted to hyphen).\n\n```ruby\nvideo = VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4', referer: 'http://my-youtube-mashup.com/',\n                                                                    user_agent: 'My YouTube Mashup Robot/1.0')\n```\n\nUser-Agent when empty defaults to \"VideoInfo/VERSION\" - where version is current VideoInfo version, e.g. **\"VideoInfo/0.2.7\"**.\n\nIt supports all `OpenURI` header fields (options), for more information see: [OpenURI docs](https://ruby-doc.org/3.2.0/stdlibs/open-uri/OpenURI.html).\n\nYou 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:\n\n```ruby\nVideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4').embed_code(iframe_attributes: { width: 800, height: 600, 'data-key' =\u003e 'value' })\n=\u003e '\u003ciframe src=\"//www.youtube.com/embed/mZqGqE0D0n4\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" width=\"800\" height=\"600\" data-key=\"value\"\u003e\u003c/iframe\u003e'\n\nVideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4').embed_code(url_attributes: { autoplay: 1 })\n=\u003e '\u003ciframe src=\"//www.youtube.com/embed/mZqGqE0D0n4?autoplay=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"\u003e\u003c/iframe\u003e'\n```\n\nIf you would like to disable certain providers, you can do so by modifying the class variable `disable_providers`:\n\n```ruby\nVideoInfo.disable_providers = %w[YouTube] # disable YouTube\nVideoInfo.disable_providers = %w[Vimeo YouTube] # disable Vimeo and Youtube\nVideoInfo.disable_providers = [] # enable all providers\n```\n\n**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.\n\n## Contributing\n\nPlease read [the contributing guidelines](CONTRIBUTING.md).\n\n### Author\n\n[Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))\n\n### Maintainers\n\n- [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))\n- [Vincent Heuken](https://github.com/vheuken)\n- [João Vieira](https://github.com/joaocv3)\n- [Marc Anguera](https://github.com/markets)\n\n### Contributors\n\nThanks to [all contributors](https://github.com/thibaudgg/video_info/graphs/contributors)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthibaudgg%2Fvideo_info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthibaudgg%2Fvideo_info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthibaudgg%2Fvideo_info/lists"}