Sha256: 11b1455cb94b68b8fb93de37d081d22616a86b45083be6b4494fc73767101c0a

Contents?: true

Size: 1.71 KB

Versions: 458

Compression:

Stored size: 1.71 KB

Contents

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 iTunes Connect.")
    end

    def self.download(options, folder_path)
      v = 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

458 entries across 458 versions & 2 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 deliver/lib/deliver/download_screenshots.rb
fastlane-2.73.0 deliver/lib/deliver/download_screenshots.rb
fastlane-2.73.0.beta.20180105010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.73.0.beta.20180104010004 deliver/lib/deliver/download_screenshots.rb
fastlane-2.73.0.beta.20180103010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20180102010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20180101010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20171231010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.1 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20171230010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20171229010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.72.0.beta.20171228010004 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171227010004 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171226010004 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171225010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171224010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171223010003 deliver/lib/deliver/download_screenshots.rb
fastlane-2.71.0.beta.20171222010003 deliver/lib/deliver/download_screenshots.rb