Last active
September 16, 2020 03:20
-
-
Save nicknmejia/0651bb456dd3e62042ee to your computer and use it in GitHub Desktop.
Revisions
-
nicknmejia revised this gist
Mar 25, 2016 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,8 @@ YouTube Channel Statistics Widget ------------------------------------------------------------ Super simple dashing widget for displaying your youtube channels stats</br><br/> Credit to ephigenia and jonasrosland for creating other youtube widgets that I pulled bits and pieces from</br> Hugs and kisses to my loved ones. Vote for Nader! -
nicknmejia revised this gist
Mar 25, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ YouTube Channel Statistics Widget Enables tracking of all video views stats in a playlist. Super simple dashing widget for displaying your youtube channels stats</br> Credit to ephigenia and jonasrosland for creating other youtube widgets that I pulled bits and pieces from</br> Hugs and kisses to my loved ones. Vote for Nader! ``` -
nicknmejia revised this gist
Mar 25, 2016 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ YouTube Channel Statistics Widget ------------------------------------------------------------ Enables tracking of all video views stats in a playlist. Super simple dashing widget for displaying your youtube channels stats Credit to ephigenia and jonasrosland for creating other youtube widgets that I pulled bits and pieces from Hugs and kisses to my loved ones. Vote for Nader! ``` <li data-row="1" data-col="1" data-sizex="3" data-sizey="1"> <div data-id="youtube_subscribers" data-view="Longnumber" data-title="Youtube Subscribers" style="background-color:#e52d27;"></div> </li> ``` -
nicknmejia created this gist
Mar 25, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env ruby require 'net/http' require 'openssl' require 'json' # Super simple dashing widget for displaying your youtube channels stats # Credit to ephigenia and jonasrosland for creating other youtube widgets that I pulled bits and pieces from # Hugs and kisses to my loved ones. Vote for Nader! # Config # ------ youtube_api_key = ENV['YOUTUBE_API_KEY'] || 'YOUR API KEY' youtube_channel_id = ENV['YOUTUBE_CHANNEL_KEY'] || 'YOUR CHANNEL ID' SCHEDULER.every '1m', :first_in => 0 do |job| http = Net::HTTP.new("www.googleapis.com", Net::HTTP.https_default_port()) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # disable ssl certificate check response = http.request(Net::HTTP::Get.new("/youtube/v3/channels?part=statistics&id=#{youtube_channel_id}&key=#{youtube_api_key}")) if response.code != "200" puts "youtube api error (status-code: #{response.code})\n#{response.body}" else data = JSON.parse(response.body) send_event('youtube_subscribers', current: data["items"][0]["statistics"]["subscriberCount"]) send_event('youtube_views', current: data["items"][0]["statistics"]["viewCount"]) send_event('youtube_videos', current: data["items"][0]["statistics"]["videoCount"]) end end