itunes_store_transporter 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03bfd32d4a15484365dbcb15dbd92ef31f26245b
4
+ data.tar.gz: 664a9e8ec021008970be52d5b25589e88f492726
5
+ SHA512:
6
+ metadata.gz: 53aacb46d02bc9303bd96521cbb0d0600fe6b065bb32cdf70d638c3d3f71466a9a2cc8dd0e9ddeb4b8a84dc0c14e3b7d14022775e33acf2fdaebb64992d1838c
7
+ data.tar.gz: 47a88fa62dd96a654f9086f35d41b9e8972eed344abae81db17878451e84bf4d0f6e18ae6076d149efeeb6765f6852b0f5569e2c2121f7fc04880beb582baa58
data/Changes CHANGED
@@ -1,3 +1,10 @@
1
+ v0.1.0 2013-04-23
2
+ --------------------
3
+ * `itms lookup` now saves metadata in an .itmsp directory as metadata.xml
4
+
5
+ Enhancements:
6
+ * `itms` added --assets option to lookup command
7
+
1
8
  v0.0.2 2012-09-23
2
9
  --------------------
3
10
  Enhancements:
data/README.rdoc CHANGED
@@ -35,7 +35,7 @@ supports the following operations:
35
35
  * Upload packages
36
36
  * Validate packages
37
37
  * Retrieve status information
38
- * Lookup package metadata
38
+ * Lookup package metadata and video assets
39
39
  * List providers
40
40
  * Retrieve iTunes metadata schemas
41
41
 
@@ -73,6 +73,30 @@ This can be fixed by modifying +iTMSTransporter.CMD+ (note that the following do
73
73
  * +COMMAND+ - The command (<code>iTunes::Store::Transporter</code> method) to run
74
74
  * +OPTIONS+ - These are quivalent to the given +COMMAND+'s options except they must be given in long option format. For example <code>:apple_id => "X123"</code> would be <code>--apple-id=X123</code>. Boolean options can be negated with the <code>--no-</code> prefix.
75
75
 
76
+ ==== Lookup command
77
+
78
+ The lookup command differs slightly from the gem by allowing you to download low-quality copies of the assets associated with the looked up metadata.
79
+ These assets are created by Apple (at the time of this writing, Apple only allows you to download full and preview assets, there is nothing
80
+ in +itms+ that would prevent you from downloading other types of assets if/when they're supported).
81
+
82
+ For example, to lookup the metadata for package +X123+ and download low-quality copies of all the assets:
83
+
84
+ itms lookup --vendor-id=X123 --assets
85
+
86
+ To download a particular asset type just provide its name:
87
+
88
+ itms lookup --vendor-id=X123 --assets=preview
89
+
90
+ If there are multiple territories this will download the preview assets for each of them. To only download assets in a given territory or territories use:
91
+
92
+ itms lookup --vendor-id=X123 --assets=preview:US
93
+ itms lookup --vendor-id=X123 --assets=preview:US:BR
94
+
95
+ If necessary multiple asset types can be seperated by a comma:
96
+
97
+ itms lookup --vendor-id=X123 --assets=full,preview
98
+ itms lookup --vendor-id=X123 --assets=full,preview:MX
99
+
76
100
  ==== Config file
77
101
 
78
102
  Default options and email notifications can be placed in a YAML file at <code>$HOME/.itms</code>. To skip loading the config file use the <code>--no-config</code> option.
@@ -120,14 +144,14 @@ As you can see, command options are turned into template variables.
120
144
 
121
145
  === More Info
122
146
 
123
- * Docs: http://ruby-doc.org/gems/docs/i/itunes_store_transporter-0.0.2/README_rdoc.html
147
+ * Docs: http://ruby-doc.org/gems/docs/i/itunes_store_transporter-0.1.0/README_rdoc.html
124
148
  * Bugs: http://github.com/sshaw/itunes_store_transporter/issues
125
149
  * Source Code: http://github.com/sshaw/itunes_store_transporter
126
150
  * Web Based GUI: http://github.com/sshaw/itunes_store_transporter_web
127
151
 
128
152
  === Author
129
153
 
130
- Skye Shaw [sshaw AT lucas.cis.temple.edu]
154
+ Skye Shaw [sshaw AT gmail.com]
131
155
 
132
156
  === License
133
157
 
data/bin/itms CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "erb"
4
+ require "uri"
4
5
  require "yaml"
5
6
  require "net/smtp"
7
+ require "net/http"
8
+ require "rexml/document"
6
9
  require "itunes/store/transporter"
7
10
 
8
11
  # Command line interface to the ITunes::Store::Transporter library.
@@ -44,11 +47,84 @@ module Command
44
47
  end
45
48
 
46
49
  class Lookup < Base
50
+ def initialize(options)
51
+ super
52
+ @assets = options.delete(:assets)
53
+ @assets = @assets.split(",").map { |x| x.split(":").grep(/\w/) } if String === @assets
54
+ @package = "#{options[:apple_id] || options[:vendor_id]}.itmsp"
55
+ Dir.mkdir(@package)
56
+ end
57
+
47
58
  def execute(args = [])
48
- filename = "#{@options[:apple_id] || @options[:vendor_id]}.xml"
49
59
  metadata = @itms.lookup
50
- File.open(filename, "w") { |f| f.write(metadata) }
51
- puts "Metadata saved to #{filename}"
60
+ File.open("#@package/metadata.xml", "w") { |f| f.write(metadata) }
61
+ puts "Metadata saved in #@package"
62
+ retrieve_assets(metadata) if @assets
63
+ end
64
+
65
+ def retrieve_assets(metadata)
66
+ doc = REXML::Document.new(metadata)
67
+ assets = build_asset_list(doc)
68
+
69
+ if assets.none?
70
+ puts "No assets found"
71
+ else
72
+ assets.each do |asset|
73
+ puts "Downloading #{asset[:type]} asset #{asset[:filename]}"
74
+ uri = URI.parse(asset[:url])
75
+
76
+ Net::HTTP.start(uri.host, uri.port) do |http|
77
+ File.open("#@package/#{asset[:filename]}", "w") do |io|
78
+ http.request_get(uri.path) do |res|
79
+ raise res.message unless Net::HTTPSuccess === res
80
+ res.read_body do |data|
81
+ io.write data
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ rescue => e
89
+ raise "Asset retrieval failed: #{e}"
90
+ end
91
+
92
+ def build_asset_list(doc)
93
+ asset_info = lambda do |xpath|
94
+ doc.get_elements(xpath).map do |e|
95
+ file = {}
96
+ file[:url] = e.get_text("//*[ @key = 'proxy-encode-url' ]").to_s
97
+ type = e.attribute("type")
98
+ file[:type] = type.value if type
99
+ file[:filename] = e.get_text(".//data_file[ @role = 'source' ]/file_name").to_s
100
+ file[:territories] = e.get_elements(".//territory").map { |t| t.get_text.to_s }
101
+ file
102
+ end
103
+ end
104
+
105
+ files = []
106
+ if @assets == true
107
+ files = asset_info["//asset[ .//*[ @key = 'proxy-encode-url' ]]"]
108
+ else
109
+ @assets.each do |asset|
110
+ type, regions = asset.shift, asset
111
+ regions.clear if type == "full" # There's only one full asset per package
112
+
113
+ xpath = "//asset[ @type = '#{type}'"
114
+ if regions.any?
115
+ xpath << " and (%s)" % regions.map { |code| ".//territory = '#{code}'" }.join(" or ")
116
+ end
117
+ xpath << "and .//*[ @key = 'proxy-encode-url' ]]"
118
+
119
+ info = asset_info[xpath]
120
+ unknown = regions - info.map { |file| file[:territories] }.flatten
121
+ raise "No #{type} asset for #{unknown.join ", "}" if unknown.any?
122
+
123
+ files.concat info
124
+ end
125
+ end
126
+
127
+ files
52
128
  end
53
129
  end
54
130
 
@@ -57,7 +133,6 @@ module Command
57
133
  filename = "#{@options[:version]}-#{@options[:type]}.rng"
58
134
  schema = @itms.schema
59
135
  File.open(filename, "w") { |f| f.write(schema) }
60
- puts "Schema saved to #{filename}"
61
136
  end
62
137
  end
63
138
 
@@ -70,7 +145,7 @@ module Command
70
145
  super
71
146
  end
72
147
 
73
- def execute(args = [])
148
+ def execute(args = [])
74
149
  info = @itms.status
75
150
  info.each do |k, v|
76
151
  next if k == :status
@@ -131,7 +206,7 @@ class Email
131
206
 
132
207
  def initialize(config = {})
133
208
  unless config["to"]
134
- raise "No email recipeints provided, you must specify at least one"
209
+ raise "No email recipients provided, you must specify at least one"
135
210
  end
136
211
 
137
212
  @config = config
@@ -264,7 +339,7 @@ rescue ITunes::Store::Transporter::ExecutionError => e
264
339
  options[:error] = e
265
340
  send_email(email_options["failure"], options)
266
341
  exit 1
267
- rescue ITunes::Store::Transporter::TransporterError => e
342
+ rescue => e
268
343
  $stderr.puts e
269
344
  exit 2
270
345
  end
@@ -1,7 +1,7 @@
1
1
  module ITunes
2
2
  module Store
3
3
  class Transporter
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,53 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes_store_transporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Skye Shaw
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-23 00:00:00.000000000Z
11
+ date: 2013-04-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: childprocess
16
- requirement: &70153694946460 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.3.2
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70153694946460
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.2
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: optout
27
- requirement: &70153694945700 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 0.0.2
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70153694945700
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rake
38
- requirement: &70153694938340 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: 0.9.2
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70153694938340
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
- requirement: &70153694937480 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -57,11 +64,18 @@ dependencies:
57
64
  version: '3'
58
65
  type: :development
59
66
  prerelease: false
60
- version_requirements: *70153694937480
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '2.9'
72
+ - - <
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
61
75
  description: ! " iTunes::Store::Transporter is a wrapper around Apple's iTMSTransporter
62
76
  program. It allows you to upload packages to the \n Apple Store, validate them,
63
77
  retrieve status information, lookup metadata, and more!\n"
64
- email: sshaw@lucas.cis.temple.edu
78
+ email: skye.shaw@gmail.com
65
79
  executables:
66
80
  - itms
67
81
  extensions: []
@@ -100,27 +114,26 @@ files:
100
114
  homepage: http://github.com/sshaw/itunes_store_transporter
101
115
  licenses:
102
116
  - MIT
117
+ metadata: {}
103
118
  post_install_message:
104
119
  rdoc_options: []
105
120
  require_paths:
106
121
  - lib
107
122
  required_ruby_version: !ruby/object:Gem::Requirement
108
- none: false
109
123
  requirements:
110
124
  - - ! '>='
111
125
  - !ruby/object:Gem::Version
112
126
  version: '0'
113
127
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
128
  requirements:
116
129
  - - ! '>='
117
130
  - !ruby/object:Gem::Version
118
131
  version: '0'
119
132
  requirements: []
120
133
  rubyforge_project:
121
- rubygems_version: 1.8.10
134
+ rubygems_version: 2.0.3
122
135
  signing_key:
123
- specification_version: 3
136
+ specification_version: 4
124
137
  summary: Upload and manage your assets in the iTunes Store using the iTunes Store's
125
138
  Transporter (iTMSTransporter).
126
139
  test_files: