如何从 TestFlight 自动下载应用构建
How to automatically download app builds from TestFlight
我有一堆应用程序上传到 Testflight。如何自动下载所有构建到我的电脑?
您可以使用 Ruby + 机械化 (https://github.com/sparklemotion/mechanize):
require 'mechanize'
@agent = Mechanize.new
def process_login_page page
puts 'Login...'
login_form = page.forms.first # form has no action or name so just take the first one
login_field = login_form.field_with(:name => 'username')
password_field = login_form.field_with(:name => 'password')
login_field.value = 'username'
password_field.value = 'password'
login_form.submit
app_link_pattern = /\/dashboard\/applications\/(.*?)\/token\//
puts 'Dashboard...'
@agent.get("https://testflightapp.com/dashboard/applications/") do |dashboard_page|
dashboard_page.links.each do |link|
link.href =~ app_link_pattern
if != nil
puts "Builds page for #{}..."
@agent.get "https://testflightapp.com/dashboard/applications/#{}/builds/" do |builds_page|
process_builds_page builds_page
end
end
end
end
end
def process_builds_page page
body = page.body
build_pages = body.scan /<tr class="goversion pointer" id="\/dashboard\/builds\/report\/(.*?)\/">/
build_pages.each do |build_id|
@agent.get "https://testflightapp.com/dashboard/builds/complete/#{build_id.first}/" do |build_page|
process_build_page build_page
end
end
end
def process_build_page page
build_link = page.links_with(:dom_class => 'bitly').first
@agent.get("https://www.testflightapp.com#{build_link.href}") { |install_page| process_install_page install_page}
end
def process_install_page page
# we need to figure out what kind of build is that
ipa_link = page.link_with(:text => "download the IPA.")
if (ipa_link != nil)
download_build ipa_link, "ipa"
else
apk_link = page.link_with(:text => "download the APK.")
if (apk_link != nil)
download_build apk_link, "apk"
end
end
end
def download_build link, file_ext
link.href =~ /\/dashboard\/ipa\/(.*?)\//
filename = "#{}.#{file_ext}"
file_url = "https://www.testflightapp.com#{link.href}"
puts "Downloading #{file_url}..."
@agent.get(file_url).save("out/#{filename}")
end
FileUtils.rm_rf "out"
Dir.mkdir "out"
login_page_url = "https://testflightapp.com/login/"
@agent.get(login_page_url) { |page| process_login_page page }
免责声明:我不是 Ruby 开发人员,此代码远非设计良好或安全。只是一个快速而肮脏的解决方案。
我有一堆应用程序上传到 Testflight。如何自动下载所有构建到我的电脑?
您可以使用 Ruby + 机械化 (https://github.com/sparklemotion/mechanize):
require 'mechanize'
@agent = Mechanize.new
def process_login_page page
puts 'Login...'
login_form = page.forms.first # form has no action or name so just take the first one
login_field = login_form.field_with(:name => 'username')
password_field = login_form.field_with(:name => 'password')
login_field.value = 'username'
password_field.value = 'password'
login_form.submit
app_link_pattern = /\/dashboard\/applications\/(.*?)\/token\//
puts 'Dashboard...'
@agent.get("https://testflightapp.com/dashboard/applications/") do |dashboard_page|
dashboard_page.links.each do |link|
link.href =~ app_link_pattern
if != nil
puts "Builds page for #{}..."
@agent.get "https://testflightapp.com/dashboard/applications/#{}/builds/" do |builds_page|
process_builds_page builds_page
end
end
end
end
end
def process_builds_page page
body = page.body
build_pages = body.scan /<tr class="goversion pointer" id="\/dashboard\/builds\/report\/(.*?)\/">/
build_pages.each do |build_id|
@agent.get "https://testflightapp.com/dashboard/builds/complete/#{build_id.first}/" do |build_page|
process_build_page build_page
end
end
end
def process_build_page page
build_link = page.links_with(:dom_class => 'bitly').first
@agent.get("https://www.testflightapp.com#{build_link.href}") { |install_page| process_install_page install_page}
end
def process_install_page page
# we need to figure out what kind of build is that
ipa_link = page.link_with(:text => "download the IPA.")
if (ipa_link != nil)
download_build ipa_link, "ipa"
else
apk_link = page.link_with(:text => "download the APK.")
if (apk_link != nil)
download_build apk_link, "apk"
end
end
end
def download_build link, file_ext
link.href =~ /\/dashboard\/ipa\/(.*?)\//
filename = "#{}.#{file_ext}"
file_url = "https://www.testflightapp.com#{link.href}"
puts "Downloading #{file_url}..."
@agent.get(file_url).save("out/#{filename}")
end
FileUtils.rm_rf "out"
Dir.mkdir "out"
login_page_url = "https://testflightapp.com/login/"
@agent.get(login_page_url) { |page| process_login_page page }
免责声明:我不是 Ruby 开发人员,此代码远非设计良好或安全。只是一个快速而肮脏的解决方案。