Skip to content

Commit

Permalink
Add TWITCHTOKEN_CLIENT_ID since you need a separate Client-ID to use …
Browse files Browse the repository at this point in the history
…the access_token endpoint now.
  • Loading branch information
stefansundin committed May 22, 2020
1 parent 358bec5 commit 17ffbe0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerenv.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ REDIS_URL=redis://redis:6379
#SOUNDCLOUD_CLIENT_ID=

#TWITCH_CLIENT_ID=
#TWITCHTOKEN_CLIENT_ID=

#IMGUR_CLIENT_ID=

Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ REDIS_URL=redis://localhost:6379/3
#SOUNDCLOUD_CLIENT_ID=

#TWITCH_CLIENT_ID=
#TWITCHTOKEN_CLIENT_ID=

#IMGUR_CLIENT_ID=

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Go to the [SoundCloud developer website](https://soundcloud.com/you/apps) and cr

Go to your [Twitch settings](https://www.twitch.tv/settings/connections) and create an app. Copy your client id.

To download Twitch videos, you also need to configure a separate client id.

#### Imgur

Go to the [Imgur settings](https://imgur.com/account/settings/apps) and create an app. Copy your client id.
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ REDIS_URL=redis://localhost:6379/3
#FACEBOOK_APP_SECRET=
#SOUNDCLOUD_CLIENT_ID=
#TWITCH_CLIENT_ID=
#TWITCHTOKEN_CLIENT_ID=
#IMGUR_CLIENT_ID=
#GOOGLE_VERIFICATION_TOKEN=googleXXXXXXXXXXXXXXXX.html
Expand Down
4 changes: 2 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@
end

get "/twitch/download" do
return [404, "Credentials not configured"] if !ENV["TWITCH_CLIENT_ID"]
return [404, "Credentials not configured"] if !ENV["TWITCHTOKEN_CLIENT_ID"]
return [400, "Insufficient parameters"] if params[:url].empty?

if /twitch\.tv\/[^\/]+\/clip\/(?<clip_slug>[^?&#]+)/ =~ params[:url] || /clips\.twitch\.tv\/(?:embed\?clip=)?(?<clip_slug>[^?&#]+)/ =~ params[:url]
Expand Down Expand Up @@ -933,7 +933,7 @@
end

get "/twitch/watch" do
return [404, "Credentials not configured"] if !ENV["TWITCH_CLIENT_ID"]
return [404, "Credentials not configured"] if !ENV["TWITCHTOKEN_CLIENT_ID"]
return [400, "Insufficient parameters"] if params[:url].empty?

if /twitch\.tv\/[^\/]+\/clip\/(?<clip_slug>[^?&#]+)/ =~ params[:url] || /clips\.twitch\.tv\/(?:embed\?clip=)?(?<clip_slug>[^?&#]+)/ =~ params[:url]
Expand Down
2 changes: 1 addition & 1 deletion app/twitch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Twitch < HTTP
class TwitchToken < HTTP
BASE_URL = "https://api.twitch.tv/api"
HEADERS = {
"Client-ID" => ENV["TWITCH_CLIENT_ID"],
"Client-ID" => ENV["TWITCHTOKEN_CLIENT_ID"],
}
ERROR_CLASS = TwitchError
end
Expand Down
1 change: 1 addition & 0 deletions kubernetes/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ data:
# FACEBOOK_APP_SECRET: ""
# SOUNDCLOUD_CLIENT_ID: ""
# TWITCH_CLIENT_ID: ""
# TWITCHTOKEN_CLIENT_ID: ""
# IMGUR_CLIENT_ID: ""
2 changes: 2 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-submit-type="highlight">Highlights only</a>
<% if ENV["TWITCHTOKEN_CLIENT_ID"] %>
<div class="dropdown-divider"></div>
<a class="dropdown-item" data-vlc="watch">Open in VLC</a>
<a class="dropdown-item" data-action="watch">Watch in external program</a>
<a class="dropdown-item" data-download>Get download command</a>
<a class="dropdown-item" data-irc="irc.chat.twitch.tv:6667">Open chat in IRC</a>
<% end %>
</div>
<input class="btn btn-primary" type="submit" value="Get RSS Feed">
</div>
Expand Down

0 comments on commit 17ffbe0

Please sign in to comment.