如何从TestFlight自动下载应用程序版本

时间:2015-01-29 23:08:42

标签: ios automation testflight

我将一堆应用程序上传到Testflight。如何自动将所有版本下载到我的电脑上?

1 个答案:

答案 0 :(得分:0)

您可以使用Ruby + Mechanize(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 $1 != nil
        puts "Builds page for #{$1}..."
        @agent.get "https://testflightapp.com/dashboard/applications/#{$1}/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 = "#{$1}.#{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开发人员,而且这段代码远非设计良好或安全。只是一个快速而肮脏的解决方案。

相关问题