wwdcdownloader 20.16.0 → 20.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0d575c5ff71a424bc262a8bf2ef2069aaa17ce
4
- data.tar.gz: 67e2e3f795a7b58a627108c04060d9dec446e61a
3
+ metadata.gz: 434cdc1a01d9bbda7696e45a6870648aa8de563d
4
+ data.tar.gz: d4732cbaaedfde0eb0541e1db03c5d6eed5e3b6d
5
5
  SHA512:
6
- metadata.gz: 8bf8883679598537f80239382c0573563f0f5b9455a37d8d2eb69dc1aefe2f3bdd0ea85f8e05bcf68fe5f1cdc47f55580cebf2fa03b157aad9400c05ad52784f
7
- data.tar.gz: f86345f261eda82c4f16cb5fae88bdfae196f9e3de523a1d686dfe54d9d9674cbcb8d247dcad5397977e262b7bab7aa6e5cd28bd7379528e3f33d35873630aa9
6
+ metadata.gz: 961178f2c810fd9c2c57eae4a8f1e18985e656b6246c6246b1330c3cc055f7054c1dd336897b620e73ff1c4e54f1e80a1008ae61516a7832aa0303e5c58a89cb
7
+ data.tar.gz: 5b75935d3e17af52501f3e146f2694bc6ea24baa46e3600158e2541a17958977df5f76240e4e3cef549d59ae4dc02d9e7a01edbf5e724fc3405bd9f3e0cfa188
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Johannes Fahrenkrug
1
+ Copyright (c) 2017 Johannes Fahrenkrug
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Readme.md CHANGED
@@ -1,10 +1,10 @@
1
- # WWDC 2016 Sample Code Downloader
1
+ # WWDC 2017 Sample Code Downloader
2
2
 
3
3
  ![First World WWDC Sample Code Problem](http://cdn.memegenerator.net/instances/400x/21928207.jpg)
4
4
 
5
5
  ## Sad days are over
6
6
 
7
- This script will download all the session material for you if you are a WWDC 2016 attendee OR NOT!
7
+ This script will download all the session material for you if you are a WWDC 2017 attendee OR NOT!
8
8
  You can now simply install WWDC-Downloader as a ruby gem like this:
9
9
 
10
10
  gem install wwdcdownloader
@@ -17,6 +17,6 @@ Run the script like this:
17
17
 
18
18
  wwdcdownloader [<target-dir>]
19
19
 
20
- The script will create a directory called "wwdc2016-assets" (or `target-dir` if given) in the directory you run the script from.
20
+ The script will create a directory called "wwdc2017-assets" (or `target-dir` if given) in the directory you run the script from.
21
21
 
22
22
  That's it. Enjoy and see you next year.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 20.16.0
1
+ 20.17.0
@@ -1,9 +1,10 @@
1
1
  # Have fun. Use at your own risk.
2
- # Copyright (c) 2016 Johannes Fahrenkrug
2
+ # Copyright (c) 2017 Johannes Fahrenkrug
3
3
 
4
4
  require 'rubygems'
5
5
  require 'fileutils'
6
6
  require 'net/http'
7
+ require 'uri'
7
8
 
8
9
  begin
9
10
  require 'json'
@@ -22,9 +23,9 @@ rescue LoadError => e
22
23
  end
23
24
 
24
25
  class WWDCDownloader
25
- #BASE_URI = 'https://developer.apple.com/wwdc-services/cy4p09ns/a4363cb15472b00287b/sessions.json'
26
+ BASE_URI = 'https://devimages-cdn.apple.com/wwdc-services/h8a19f8f/049CCC2F-0D8A-4F7D-BAB9-2D8F5BAA7030/contents.json'
26
27
 
27
- WWDC_LIBRARIES = [{:base => 'https://developer.apple.com/library/prerelease/content', :lib => '/navigation/library.json'}]
28
+ WWDC_LIBRARIES = [{:base => 'https://developer.apple.com/library/content', :lib => '/navigation/library.json'}]
28
29
 
29
30
  attr_accessor :downloaded_files, :dl_dir, :min_date, :proxy_uri
30
31
 
@@ -118,6 +119,66 @@ class WWDCDownloader
118
119
  def load
119
120
  mkdir(dl_dir)
120
121
 
122
+ # get the sessions JSON
123
+ self.read_url(BASE_URI) do |body|
124
+ res = JSON.parse(body)
125
+
126
+ sessions = res['contents']
127
+ resources = res['resources']
128
+
129
+ if sessions.size > 0
130
+
131
+ sessions.each do |session|
132
+ if session['type'] == 'Session' && session['eventId'] == 'wwdc2017'
133
+ title = session['title']
134
+ session_id = session['id'].gsub('wwdc2017-', '')
135
+ puts "Session #{session_id} '#{title}'..."
136
+
137
+ if session['related'] && session['related']['resources']
138
+ # Iterate over the resources
139
+ related_resource_ids = session['related']['resources']
140
+ did_download = false
141
+
142
+ # get the files
143
+ dirname = "#{dl_dir}/#{session_id}-#{title.gsub(/\/|&|!/, '')}"
144
+ puts " Creating #{dirname}"
145
+ did_create_dir = mkdir(dirname)
146
+
147
+ resources.each do |resource|
148
+ if resource['resource_type'] == 'samplecode' && related_resource_ids.include?(resource['id'])
149
+ puts " Found related resource #{resource['url']}"
150
+
151
+ # Zip file? download right away
152
+ if resource['url'] =~ /(\w+\.zip)$/
153
+ uri = URI.parse(resource['url'])
154
+ filename = File.basename(uri.path)
155
+
156
+ if download_file(resource['url'], filename, dirname, true)
157
+ did_download = true
158
+ end
159
+ # Sample code landing page?
160
+ else
161
+ # Sanitize URL
162
+ url = resource['url'].split('/Introduction/Intro.html')[0]
163
+
164
+ if download_sample_code_from_book_json("#{url}/book.json", url, dirname, false)
165
+ did_download = true
166
+ end
167
+ end
168
+ end
169
+ end
170
+
171
+ if !did_download and did_create_dir
172
+ Dir.delete(dirname)
173
+ end
174
+ end
175
+ end
176
+ end
177
+ else
178
+ print "No sessions :(.\n"
179
+ end
180
+ end
181
+
121
182
  # scrape the WWDC libraries...
122
183
  puts
123
184
  puts "Scraping the WWDC libraries..."
@@ -165,7 +226,7 @@ class WWDCDownloader
165
226
  end
166
227
 
167
228
  def self.run!(*args)
168
- puts "WWDC 2016 Session Material Downloader"
229
+ puts "WWDC 2017 Session Material Downloader"
169
230
  puts "by Johannes Fahrenkrug, @jfahrenkrug, springenwerk.com"
170
231
  puts "See you next year!"
171
232
  puts
@@ -175,10 +236,10 @@ class WWDCDownloader
175
236
  dl_dir = if args.size == 1
176
237
  args.last
177
238
  else
178
- 'wwdc2016-assets'
239
+ 'wwdc2017-assets'
179
240
  end
180
241
 
181
- w = WWDCDownloader.new(dl_dir, '2016-06-01')
242
+ w = WWDCDownloader.new(dl_dir, '2017-06-01')
182
243
  w.load
183
244
  return 0
184
245
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wwdcdownloader"
8
- s.version = "20.16.0"
8
+ s.version = "20.17.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Johannes Fahrenkrug"]
12
- s.date = "2016-06-23"
12
+ s.date = "2017-06-07"
13
13
  s.description = "At each year's WWDC, Apple releases great sample projects. Unfortunately it is very tedious to manually download all these treasures through your browser. WWDC-Downloader solves this problem for you!"
14
14
  s.email = "johannes@springenwerk.com"
15
15
  s.executables = ["wwdcdownloader"]
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.homepage = "https://github.com/jfahrenkrug/WWDC-Downloader"
31
31
  s.licenses = ["MIT"]
32
32
  s.require_paths = ["lib"]
33
- s.rubygems_version = "2.0.14"
33
+ s.rubygems_version = "2.0.14.1"
34
34
  s.summary = "A small tool to download all the sample code of Apple's latest WWDC developer conference"
35
35
 
36
36
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wwdcdownloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 20.16.0
4
+ version: 20.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Fahrenkrug
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.0.14
94
+ rubygems_version: 2.0.14.1
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: A small tool to download all the sample code of Apple's latest WWDC developer