Sha256: 7739ae9eaa04f2f4ca40706d70480f4f99a03412ed9c9d466ddd320531d11f8e

Contents?: true

Size: 1.87 KB

Versions: 203

Compression:

Stored size: 1.87 KB

Contents

require_relative 'module'
require 'open-uri'

module Deliver
  class DownloadScreenshots
    def self.run(options, path)
      UI.message("Downloading all existing screenshots...")
      download(options, path)
      UI.success("Successfully downloaded all existing screenshots")
    rescue => ex
      UI.error(ex)
      UI.error("Couldn't download already existing screenshots from App Store Connect.")
    end

    def self.download(options, folder_path)
      v = options[:use_live_version] ? options[:app].live_version(platform: options[:platform]) : options[:app].latest_version(platform: options[:platform])

      v.screenshots.each do |language, screenshots|
        screenshots.each do |screenshot|
          file_name = [screenshot.sort_order, screenshot.device_type, screenshot.sort_order].join("_")
          original_file_extension = File.basename(screenshot.original_file_name)
          file_name += "." + original_file_extension

          UI.message("Downloading existing screenshot '#{file_name}' for language '#{language}'")

          # If the screen shot is for an appleTV we need to store it in a way that we'll know it's an appleTV
          # screen shot later as the screen size is the same as an iPhone 6 Plus in landscape.
          if screenshot.device_type == "appleTV"
            containing_folder = File.join(folder_path, "appleTV", screenshot.language)
          else
            containing_folder = File.join(folder_path, screenshot.language)
          end

          if screenshot.is_imessage
            containing_folder = File.join(folder_path, "iMessage", screenshot.language)
          end

          begin
            FileUtils.mkdir_p(containing_folder)
          rescue
            # if it's already there
          end
          path = File.join(containing_folder, file_name)
          File.binwrite(path, open(screenshot.url).read)
        end
      end
    end
  end
end

Version data entries

203 entries across 203 versions & 2 rubygems

Version Path
fastlane-2.123.0.beta.20190514200021 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190513200032 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190512200017 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190511200023 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190510200014 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190509200030 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190508200056 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190507200014 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190506200027 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190505200037 deliver/lib/deliver/download_screenshots.rb
fastlane-2.123.0.beta.20190504200051 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190502200046 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190501200015 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190430200043 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190429200122 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190428200018 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190427200023 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190426200020 deliver/lib/deliver/download_screenshots.rb
fastlane-2.122.0.beta.20190425200104 deliver/lib/deliver/download_screenshots.rb