Skip to content

Commit

Permalink
I thought the new Twitch API did not include live videos, but it does…
Browse files Browse the repository at this point in the history
…. Luckily we can use thumbnail_url to filter them out. Annoying.
  • Loading branch information
stefansundin committed Oct 31, 2018
1 parent 3f706a5 commit c7ec472
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app.rb
Expand Up @@ -1035,6 +1035,9 @@
@data = response.json["data"]
@alternate_url = Addressable::URI.parse("https://www.twitch.tv/directory/game/#{game_name}").normalize.to_s

# live broadcasts show up here too, and the simplest way of filtering them out seems to be to see if thumbnail_url is populated or not
@data.reject! { |v| v["thumbnail_url"].empty? }

@title = game_name
@title += " highlights" if type == "highlight"
@title += " on Twitch"
Expand All @@ -1057,6 +1060,9 @@
user = @data[0]["user_name"] || CGI.unescape(user)
@alternate_url = Addressable::URI.parse("https://www.twitch.tv/#{user.downcase}").normalize.to_s

# live broadcasts show up here too, and the simplest way of filtering them out seems to be to see if thumbnail_url is populated or not
@data.reject! { |v| v["thumbnail_url"].empty? }

@title = user
@title += "'s highlights" if type == "highlight"
@title += " on Twitch"
Expand Down

0 comments on commit c7ec472

Please sign in to comment.