Sha256: 839c36fc4236595dcf1b2f4befd41f2ace985a87b03d79ff0adc0b7137b336b9

Contents?: true

Size: 1.79 KB

Versions: 48

Compression:

Stored size: 1.79 KB

Contents

require_relative 'module'

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 : options[:app].latest_version

      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.write(path, open(screenshot.url).read)
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
fastlane-2.113.0.beta.20190104200013 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20190103200013 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20190102200016 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20190101200013 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181231200027 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181230200014 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181229200101 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181228200027 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181227200058 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181226200116 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181225200026 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181224200038 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181223200038 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181222200027 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181221200014 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181220200101 deliver/lib/deliver/download_screenshots.rb
fastlane-2.113.0.beta.20181219200044 deliver/lib/deliver/download_screenshots.rb
fastlane-2.112.0 deliver/lib/deliver/download_screenshots.rb
fastlane-2.112.0.beta.20181218200038 deliver/lib/deliver/download_screenshots.rb
fastlane-2.112.0.beta.20181217200025 deliver/lib/deliver/download_screenshots.rb