enklawa 0.0.1 → 0.0.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjQyOTExMjY5MTJlY2UzYmU2YzA4OWQ1NjgyM2IxY2VjY2FmZjhlOA==
4
+ MzVmOWRkYjE3MmJjZjgyY2IwOTU0NTk4MGZhMGJmMDE5ODlhOGU5Yw==
5
5
  data.tar.gz: !binary |-
6
- MjJlOTI1MmU3YjBiZjkwNDZkMTM3OWNmOGVjNjdiMGFmZTFkYzlkNw==
6
+ ZDEwMmI5NGNmMTkwOWM5NjJlZTFjOTE1MjI5MDA3NmI0NjhiODllZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWE3ZGIzNWRlYTNiMjg0ZmU3NWZjNTNmYmYwMDM2M2I1ZThjM2EwYWE1ZTFl
10
- YTVmNTI1ZmYzN2RmYzA3MGNmMTk0MGVkNmU3MWRiZDhhZTZjNWVhOTMzNjJl
11
- ZTYxNjYxYWU4M2FjNTNhNTA1YmI2NDdiY2ViYzY0NDA5NmU1M2I=
9
+ MGU5MDMxZTgyMDBlYmExYTQ4ZTcyMTQwYmY0NDJjMTM4YWYyM2NhMzY5N2Jj
10
+ OGY4NGE1MTdhMDdkMzQ3YTY2YjkwYWZjNWI0NjBjMmY4YmQzMWJhZTM5OTk2
11
+ NmI4YmEzYzY4YjVhNTJhNTY3YjNkZjhjNWQwOTQ3ZDY2MzY2Yjk=
12
12
  data.tar.gz: !binary |-
13
- MDhlZTE0OGEzODc0YmUzYjU1ODBmYTU3ZjJiZDUwYTFmOTY3OWFhZjY4MTMx
14
- NjA2NTRkMTUwYzNhZDZiZmIxZTNlMjdmZjg1YTk4ZDU4YjE2ZDZhMzdkN2E1
15
- M2MxNGRlNmFjMDQyYmFjYmQwYmFlNjQ4MWFhMzZkOWNmMGVjNDk=
13
+ ODI0M2RjMDcyNzllNzIxNDVhMDFmYmE5NTZmM2ExNDJjZDAzOWU3ZmNhMzg1
14
+ NzA3YmE0MjUwY2UyOGVjZjg3MzcyNzkzOWY3MGY5MzBmNGM2ODkyODEyZGI0
15
+ OTMzZWZiYzViZWEyYzAyMTQ2OWRmYzQ4OTAyODRlZWUzOTg2ZWU=
data/README.md CHANGED
@@ -1,28 +1,26 @@
1
- # Enklawa::Api
1
+ # Enklawa API
2
2
 
3
- TODO: Write a gem description
3
+ This gem provides simple api wrapper for enklawa.net radio resources like programs and episodes. Everything is stored in one json file for easy fetching.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Install it using rubygems:
8
8
 
9
- gem 'enklawa-api'
9
+ $ gem install enklawa-api
10
10
 
11
- And then execute:
11
+ ## Usage
12
12
 
13
- $ bundle
13
+ Next you can use it to download all programs:
14
14
 
15
- Or install it yourself as:
15
+ $ enklawa save output.json
16
16
 
17
- $ gem install enklawa-api
18
-
19
- ## Usage
17
+ ## Example output
20
18
 
21
- TODO: Write usage instructions here
19
+ <http://enklawa.macbury.ninja/>
22
20
 
23
21
  ## Contributing
24
22
 
25
- 1. Fork it ( https://github.com/[my-github-username]/enklawa-api/fork )
23
+ 1. Fork it ( https://github.com/macbury/enklawa-api/fork )
26
24
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
25
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
26
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,9 +1,20 @@
1
+ require "uri"
2
+ require "net/http"
3
+
1
4
  module Enklawa
2
5
  module Api
3
- class Episode < Struct.new(:id, :name, :description, :mp3, :pub_date, :link, :duration)
6
+ class Episode < Struct.new(:id, :name, :description, :mp3, :pub_date, :link, :duration, :image)
7
+
8
+ def check_if_image_exists_or_use_from_program(program)
9
+ self.image = "http://www.enklawa.net/images/episodes/#{id}.jpg"
10
+
11
+ uri = URI(image)
4
12
 
5
- def image
6
- "http://www.enklawa.net/images/episodes/#{id}.jpg"
13
+ request = Net::HTTP.new uri.host
14
+ response = request.request_head uri.path
15
+ unless response.code.to_i == 200
16
+ self.image = program.image
17
+ end
7
18
  end
8
19
 
9
20
  def to_h
@@ -65,6 +65,7 @@ module Enklawa
65
65
  episode.pub_date = entry.published
66
66
 
67
67
  if episode.mp3
68
+ episode.check_if_image_exists_or_use_from_program(program)
68
69
  episode.duration = entry.enclosure_length.to_i
69
70
  program << episode
70
71
  end
@@ -1,5 +1,5 @@
1
1
  module Enklawa
2
2
  module Api
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enklawa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkadiusz Buras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-07 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json