Skip to content

Commit

Permalink
Periscope fix. Add User-Agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Mar 22, 2019
1 parent 1f8302e commit 7254eba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
doc = Nokogiri::HTML(response.body)
data = doc.at("div#page-container")["data-store"]
json = JSON.parse(data)
username, user_id = json["UserCache"]["usernames"][0]
username, user_id = json["UserCache"]["usernames"].to_a[0]

redirect Addressable::URI.new(path: "/periscope/#{user_id}/#{username}").normalize.to_s
end
Expand Down
3 changes: 3 additions & 0 deletions app/periscope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class PeriscopeError < HTTPError; end

class Periscope < HTTP
BASE_URL = "https://api.periscope.tv/api/v2"
HEADERS = {
"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:65.0) Gecko/20100101 Firefox/65.0",
}
ERROR_CLASS = PeriscopeError

# The session_id is valid for one hour
Expand Down

0 comments on commit 7254eba

Please sign in to comment.