nokaya 0.1.1 → 0.1.2

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: 9d3963d242f5b924de763a5549f26a2c23ff480e
4
- data.tar.gz: 01129dc6b118913ba2452adba063a25247133481
3
+ metadata.gz: 829ce1f0a2fb95b1457d4468404cfdd2d8182d79
4
+ data.tar.gz: 4557e163eaf1a75d5ca16b278d86c78a49a825a9
5
5
  SHA512:
6
- metadata.gz: 6019e2867b567f8586d22b09ca1a3a887d1cc46a4d211676f84a6ac3c0e4a98dc2e47ef543e41d46d90f71a23be246512b01d8f718ba212f681d7ba2752c4eaa
7
- data.tar.gz: 354ebc4eb8dee9d2c28bfd286fc89a4d9e29cc441dd8161f9c8f658ec57e73444ae879e2fe17cb6cff2036101419e2d7aeeaad2da499bf776abdde72cb39ef45
6
+ metadata.gz: 66c8937d7a0068491ba9b5e9222c56ebe2129de35f90d2adddb80adbc71af428fe304e6f43f53df78971a07acb0f7bcd1d7dcb2f1aaeabb6e2b37bb4e91231fb
7
+ data.tar.gz: 1439a5f81f8f8de3b9c321e394a4345d233d1138a9c7803e44cf2b6e76dce307a9433989ba864c61db68b1021ef9b53eb22c40be647f5e5a49f9ba63dc944fec
@@ -1,3 +1,14 @@
1
+ # 0.1.2
2
+
3
+ - New: appstore. Download icons + screenshots for an app name. Default: OSX, option for iOS.
4
+ - New: musicstore. Download available art for an iTunes Store song/album.
5
+ - Fix: movie command description
6
+ - Fix: optional options (yeah) for usage without CLI
7
+
8
+ # 0.1.1
9
+
10
+ - Fix: file missing
11
+
1
12
  # 0.1.0
2
13
 
3
14
  - Major internal refactoring
data/README.md CHANGED
@@ -16,7 +16,7 @@ Mac OS X only for the time being.
16
16
 
17
17
  `nokaya -i url`
18
18
 
19
- Also accepts the IFTTT format (like 'http://ift.tt/1m2Nvz8').
19
+ Also accepts the IFTTT format (like `http://ift.tt/1m2Nvz8`).
20
20
 
21
21
  Example:
22
22
 
@@ -126,14 +126,48 @@ Use option `-a` to get an alternative.
126
126
 
127
127
  This is useful for remakes:
128
128
 
129
- `nokaya movie solaris`
129
+ `nokaya -m solaris`
130
130
 
131
131
  (gives the 2002 version)
132
132
 
133
- `nokaya movie -a solaris`
133
+ `nokaya -m -a solaris`
134
134
 
135
135
  (gives the 1972 version)
136
136
 
137
+ ### App store
138
+
139
+ Downloads a set of icons and screenshots for a given app name.
140
+
141
+ Defaults for Mac OSX, use option `-i` for iOS.
142
+
143
+ `nokaya appstore name`
144
+
145
+ Examples:
146
+
147
+ `nokaya -as marked`
148
+
149
+ `nokaya -as -i chimp app.net`
150
+
151
+ ### Music store
152
+
153
+ Downloads available art for an iTunes Store song.
154
+
155
+ Works better if you embed separate elements between quotes.
156
+
157
+ `nokaya music 'song'`
158
+
159
+ `nokaya music 'song' 'artist' 'album'`
160
+
161
+ Examples:
162
+
163
+ `nokaya -z 'stairway to heaven'`
164
+
165
+ `nokaya -z 'stairway to heaven' 'led zeppelin'`
166
+
167
+ Use the `--album` option to find an album intead of a song:
168
+
169
+ `nokaya -z --album 'calamari tuesday'`
170
+
137
171
  ## Options
138
172
 
139
173
  ### Name
@@ -161,3 +195,40 @@ The picture(s) will be downloaded in '~/Downloads' if no output specified.
161
195
  Specify both.
162
196
 
163
197
  `nokaya -i http://instagram.com/p/noANAfjJ7B/ -o ~/Pics -n happy_dog`
198
+
199
+ ## Using Nokaya in a script or irb
200
+
201
+ Create a new instance of the class you need, with an array of arguments and an hash of options.
202
+
203
+ Do what you wish with this object, or call its `save` method to write down the grabbed file(s).
204
+
205
+ ```
206
+ require 'nokaya'
207
+ result = Nokaya::Movie.new ['terminator']
208
+ result.save
209
+ ```
210
+
211
+ ![Nokaya object](http://dl.dropboxusercontent.com/s/4ix4j16a004iwvd/nokaya-object.png)
212
+
213
+
214
+ The argument(s) for the movie/music/app/url - for the request - *have* to be in an array.
215
+
216
+ You can pass options in a hash. Options keys are strings that match the name of the corresponding symbol in the Nokaya::App class (which is the CLI interface).
217
+
218
+ Examples:
219
+
220
+ ```
221
+ require 'nokaya'
222
+ client = Nokaya::Movie.new ['solaris'], {'alt' => true}
223
+ client = Nokaya::Instagram.new ['http://ift.tt/1m2Nvz8'], {'output' => '/hdd/custom/dir', 'name' => 'pasta.jpg'}
224
+ client = Nokaya::Deviantart.new ['http://www.deviantart.com/photography/nature/waterscapes/']
225
+ client = Nokaya::ImgurAlbum.new ['http://imgur.com/a/JNzjB\#0']
226
+ client = Nokaya::AppStore.new ['marked app']
227
+ client = Nokaya::AppStore.new ['chimp', 'app.net'], {'ios' => true}
228
+ ```
229
+
230
+ etc.
231
+
232
+
233
+
234
+
@@ -2,5 +2,7 @@
2
2
  require 'thor'
3
3
  require 'open-uri'
4
4
  require 'nokogiri'
5
+ require 'cgi'
6
+ require 'json'
5
7
  require_relative 'nokaya/version'
6
8
  require_relative 'nokaya/app'
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
2
  module Nokaya
3
+
3
4
  class ADN < Basic
4
5
 
5
6
  attr_reader :author
6
7
 
7
- def initialize args, options
8
+ def initialize args, options = {}
8
9
  super(args, options)
9
10
  @type = :adn
10
11
  parsed = self.parse(args[0])
@@ -1,12 +1,13 @@
1
1
  # encoding: utf-8
2
2
  module Nokaya
3
+
3
4
  class App < Thor
4
5
 
5
6
  package_name "Nokaya"
6
7
 
7
- %w{basic status movie workers instagram favd adn tumblr tumblr_album imgur_album flickr_album photonet deviantart imageshack_user}.each {|file| require_relative "#{file}"}
8
+ %w{basic status movie workers instagram favd adn tumblr tumblr_album imgur_album flickr_album photonet deviantart imageshack_user apple appstore musicstore}.each {|file| require_relative "#{file}"}
8
9
 
9
- desc "movie TITLE", "Get the movie poster from IMDb (nokaya -m url)"
10
+ desc "movie TITLE", "Get the movie poster from IMDb (nokaya -m title)"
10
11
  map "-m" => :movie
11
12
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
12
13
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
@@ -18,6 +19,28 @@ module Nokaya
18
19
  puts Status.saved(image)
19
20
  end
20
21
 
22
+ desc "appstore NAME", "Get a set of icons and screenshots for Apple apps (nokaya -as name)"
23
+ map "-as" => :appstore
24
+ option :output, aliases: "-o", type: :string, desc: "Specify an output path"
25
+ option :ios, aliases: "-i", type: :boolean, desc: "Search iOS apps instead of Mac OSX apps"
26
+ def appstore *args
27
+ puts Status.wait
28
+ image = AppStore.new(args, options)
29
+ image.save
30
+ puts Status.saved_album(image)
31
+ end
32
+
33
+ desc "music NAME", "Get available art for an iTunes Store song (nokaya -z name)"
34
+ map "-z" => :music
35
+ option :output, aliases: "-o", type: :string, desc: "Specify an output path"
36
+ option :album, type: :boolean, desc: "Find an album instead of a track"
37
+ def music *args
38
+ puts Status.wait
39
+ image = MusicStore.new(args, options)
40
+ image.save
41
+ puts Status.saved_album(image)
42
+ end
43
+
21
44
  desc "instagram URL", "Get the original picture from an Instagram page (nokaya -i url)"
22
45
  map "-i" => :instagram
23
46
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+
4
+ class Apple < Basic
5
+
6
+ def initialize args, options
7
+ super(args, options)
8
+ if options['ios']
9
+ @entity = "software"
10
+ elsif options['itunes']
11
+ if options['album']
12
+ @entity = 'album'
13
+ else
14
+ @entity = "musicTrack"
15
+ end
16
+ else
17
+ @entity = "macSoftware"
18
+ end
19
+ end
20
+
21
+ def create_url terms
22
+ URI.parse("http://itunes.apple.com/search?term=#{CGI.escape(terms.join(" "))}&entity=#{@entity}")
23
+ end
24
+
25
+ def music_url terms
26
+ url = "http://itunes.apple.com/search?entity=#{@entity}"
27
+ terms.each {|term| url << "&term=#{CGI.escape(term)}"}
28
+ URI.parse(url)
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+
4
+ # Inspired by Brett Terpstra
5
+
6
+ class AppStore < Apple
7
+
8
+ attr_accessor :appname
9
+
10
+ def initialize args, options = {}
11
+ super(args, options)
12
+ @type = :appstore
13
+ @appname = @workers.sanitize(args.join('_'))
14
+ @image_url = [grab_small(args), grab_big(args)].compact
15
+ find_screenshots(args)
16
+ @path = "#{@path}/appstore-#{@appname}-#{@workers.timed}"
17
+ @file_name = name()
18
+ remove_instance_variable(:@res)
19
+ end
20
+
21
+ private
22
+
23
+ def name
24
+ @image_url.map.with_index do |url, index|
25
+ "#{@type.to_s}-#{@appname}-#{'%02d' % index}-#{File.basename(url).gsub('ApplicationIcon.', '')}"
26
+ end
27
+ end
28
+
29
+ def find_icon terms
30
+ itunes_url = self.create_url(terms)
31
+ @res = open(itunes_url).read
32
+ match = @res.match(/"#{@icon_size}":"(.*?)",/)
33
+ unless match.nil?
34
+ return match[1]
35
+ else
36
+ return false
37
+ end
38
+ end
39
+
40
+ def grab_small args
41
+ @icon_size = "artworkUrl60"
42
+ find_icon(args)
43
+ end
44
+
45
+ def grab_big args
46
+ @icon_size = "artworkUrl100"
47
+ find_icon(args)
48
+ end
49
+
50
+ def find_screenshots terms
51
+ res = JSON.parse(@res)
52
+ res['results'][0]['screenshotUrls'].each {|link| @image_url << link}
53
+ end
54
+
55
+ end
56
+ end
@@ -3,7 +3,8 @@ module Nokaya
3
3
 
4
4
  class Basic
5
5
 
6
- attr_reader :options, :args, :image_url, :path, :file_name, :type, :name
6
+ attr_reader :options, :args, :file_name, :type, :name, :path
7
+ attr_accessor :image_url
7
8
 
8
9
  def initialize args, options
9
10
  @options = options
@@ -14,6 +15,7 @@ module Nokaya
14
15
  @path = @workers.path
15
16
  @type = :basic
16
17
  @name = options['name'] if options['name']
18
+ @platform = RbConfig::CONFIG['host_os']
17
19
  end
18
20
 
19
21
  def get_basic page
@@ -3,7 +3,7 @@ module Nokaya
3
3
 
4
4
  class Deviantart < Basic
5
5
 
6
- def initialize args, options
6
+ def initialize args, options = {}
7
7
  super(args, options)
8
8
  @type = :deviantart
9
9
  parsed = self.parse(args[0])
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
2
  module Nokaya
3
+
3
4
  class Favd < Basic
4
5
 
5
6
  attr_reader :author
6
7
 
7
- def initialize args, options
8
+ def initialize args, options = {}
8
9
  super(args, options)
9
10
  @type = :favd
10
11
  parsed = self.parse(args[0])
@@ -5,7 +5,7 @@ module Nokaya
5
5
 
6
6
  attr_reader :author
7
7
 
8
- def initialize args, options
8
+ def initialize args, options = {}
9
9
  super(args, options)
10
10
  @type = :flickr
11
11
  parsed = self.parse(args[0])
@@ -3,7 +3,7 @@ module Nokaya
3
3
 
4
4
  class ImageshackUser < Basic
5
5
 
6
- def initialize args, options
6
+ def initialize args, options = {}
7
7
  super(args, options)
8
8
  @type = :imageshack
9
9
  parsed = self.parse(args[0])
@@ -5,7 +5,7 @@ module Nokaya
5
5
 
6
6
  attr_reader :author
7
7
 
8
- def initialize args, options
8
+ def initialize args, options = {}
9
9
  super(args, options)
10
10
  @type = :imgur
11
11
  parsed = self.parse(args[0])
@@ -5,7 +5,7 @@ module Nokaya
5
5
 
6
6
  attr_reader :author
7
7
 
8
- def initialize args, options
8
+ def initialize args, options = {}
9
9
  super(args, options)
10
10
  @type = :instagram
11
11
  parsed = self.parse(args[0])
@@ -7,7 +7,7 @@ module Nokaya
7
7
 
8
8
  attr_reader :title, :ref_url, :year
9
9
 
10
- def initialize args, options
10
+ def initialize args, options = {}
11
11
  super(args, options)
12
12
  @type = :movie
13
13
  resp = Spotlite::Movie.find(@args.join(' '))
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+
4
+ class MusicStore < Apple
5
+
6
+ def initialize args, options = {}
7
+ options = options.dup
8
+ options['itunes'] = true
9
+ super(args, options)
10
+ @type = :musicstore
11
+ find(args)
12
+ @path = "#{@path}/musicstore-#{@workers.sanitize(args.join(' '))}-#{@workers.timed}"
13
+ end
14
+
15
+ private
16
+
17
+ def find args
18
+ url = self.music_url(args)
19
+ data = get(url)
20
+ data['results'].each do |obj|
21
+ next if obj['collectionName'].nil?
22
+ link = obj['artworkUrl100'].gsub('100x100', '1200x1200')
23
+ next if @image_url.include?(link)
24
+ @image_url << link
25
+ @file_name << "#{@workers.sanitize(obj['collectionName'])}.jpg"
26
+ end
27
+ end
28
+
29
+ def get url
30
+ JSON.parse(open(url).read)
31
+ end
32
+
33
+ end
34
+ end
@@ -3,7 +3,7 @@ module Nokaya
3
3
 
4
4
  class Photonet < Basic
5
5
 
6
- def initialize args, options
6
+ def initialize args, options = {}
7
7
  super(args, options)
8
8
  @type = :photonet
9
9
  parsed = self.parse(args[0])
@@ -2,7 +2,7 @@
2
2
  module Nokaya
3
3
  class Tumblr < Basic
4
4
 
5
- def initialize args, options
5
+ def initialize args, options = {}
6
6
  super(args, options)
7
7
  @type = :tumblr
8
8
  parsed = self.parse(args[0])
@@ -3,7 +3,7 @@ module Nokaya
3
3
 
4
4
  class TumblrAlbum < Basic
5
5
 
6
- def initialize args, options
6
+ def initialize args, options = {}
7
7
  super(args, options)
8
8
  @type = :tumblr
9
9
  parsed = self.parse(args[0])
@@ -1,3 +1,3 @@
1
1
  module Nokaya
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -142,6 +142,8 @@ files:
142
142
  - lib/nokaya.rb
143
143
  - lib/nokaya/adn.rb
144
144
  - lib/nokaya/app.rb
145
+ - lib/nokaya/apple.rb
146
+ - lib/nokaya/appstore.rb
145
147
  - lib/nokaya/basic.rb
146
148
  - lib/nokaya/deviantart.rb
147
149
  - lib/nokaya/favd.rb
@@ -150,6 +152,7 @@ files:
150
152
  - lib/nokaya/imgur_album.rb
151
153
  - lib/nokaya/instagram.rb
152
154
  - lib/nokaya/movie.rb
155
+ - lib/nokaya/musicstore.rb
153
156
  - lib/nokaya/photonet.rb
154
157
  - lib/nokaya/status.rb
155
158
  - lib/nokaya/tumblr.rb