Skip to content

Commit

Permalink
u3d: issue encountered retrieving cache.json, the unity forums reques…
Browse files Browse the repository at this point in the history
…t continues to redirect to login required; using an empty map to bypass; grabbing change to use user agent: DragonBox@8e89fa0
  • Loading branch information
chazix committed Jun 9, 2023
1 parent 7d1a018 commit 2de960e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/u3d/unity_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ class << self

def list_available
UI.message 'Loading Unity releases'
versions = @unity_forums.pagination_urls(UNITY_LINUX_DOWNLOADS).map do |page_url|
list_available_from_page(@unity_forums, unity_forums.page_content(page_url))
end.reduce({}, :merge)
#versions = @unity_forums.pagination_urls(UNITY_LINUX_DOWNLOADS).map do |page_url|
# list_available_from_page(@unity_forums, unity_forums.page_content(page_url))
#end.reduce({}, :merge)

# [06/08/23] this is not working anymore, unity forums proceeds to redirect to require login page
# so we just use an empty map to bypass this forum check process
versions = {}

versions_fetcher = VersionsFetcher.new(pattern: LINUX_INSTALLER)
versions.merge!(versions_fetcher.fetch_json('linux'))
Expand Down
8 changes: 8 additions & 0 deletions lib/u3d/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module Utils
# Regex to capture each part of a version string (0.0.0x0)
CSIDL_LOCAL_APPDATA = 0x001c
UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/
MOZILLA_AGENT_HEADER = {
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
}.freeze

class << self
def final_url(url, redirect_limit: 10)
Expand All @@ -53,6 +56,11 @@ def page_content(url, redirect_limit: 10, request_headers: {})

def follow_redirects(url, redirect_limit: 10, http_method: :get, request_headers: {}, &block)
raise 'Too many redirections' if redirect_limit.zero?

UI.message "accessing url: #{url}"
# Unity blocks the default Ruby agent, use another one
request_headers = MOZILLA_AGENT_HEADER.merge(request_headers)

response = nil
request = nil
uri = URI(url)
Expand Down

0 comments on commit 2de960e

Please sign in to comment.