junkie 0.0.15 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cee9998ed6619f25ad25d6ecf5a0b1630e590f62
4
- data.tar.gz: 167176d895dcde45b58d63d01bcda1678dcda5dd
3
+ metadata.gz: 7a4dbf5c630d92490879347140c6444521c1a938
4
+ data.tar.gz: 73f496cb2a66aa3ac8fa51594123f0d540ee6614
5
5
  SHA512:
6
- metadata.gz: a8d7c7baa3489f5a1ea4bf4e81d1766662e20edb4cf77742b435be03c5ad33f7fd09b88a2e9f1a0b20436917b214b6ff84957244190f11650a4e57eadcff78cd
7
- data.tar.gz: b4824a30267a7b4e0b382d33bb8f2f6ad9c4e7424cd0d9d88d40367ba889110d41082fe9cfd225b2c029740f709d147fc0f563c00c42a3d38a2c2e99fb083df2
6
+ metadata.gz: 178036fb83a0a40e5644e9f3f5e74d269f39b9f8460abe8f15a0dca0d38ba64d1e0b26433c9c35222d8e4799243959ef1666e63d174aab2c1d6c39327cc70497
7
+ data.tar.gz: 681339370cac8ce58001ad6e56c8dd11bbaa34e19172c5be26ae86ee3d3fd1d14279a4e4d21c22f28a3d23cb9c8e775c500a120c76c782deab6f60a0cac1a29d
data/junkie.gemspec CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |gem|
23
23
  gem.add_runtime_dependency('yajl-ruby', ["~> 1.1.0"])
24
24
  gem.add_runtime_dependency('nokogiri', [">= 1.5"])
25
25
  gem.add_runtime_dependency('hashconfig', [">= 0.0.2"])
26
- gem.add_runtime_dependency('serienrenamer', [">= 0.0.1"])
26
+ gem.add_runtime_dependency('serienrenamer', [">= 0.2.0"])
27
27
  gem.add_runtime_dependency('sjunkieex', [">= 0.0.1"])
28
- gem.add_runtime_dependency('sindex', [">= 0.0.1"])
28
+ gem.add_runtime_dependency('sindex', [">= 0.2.5"])
29
29
  gem.add_runtime_dependency('logging', ["~> 1.8.0"])
30
30
  gem.add_runtime_dependency('twitter', ["~> 4.4.0"])
31
- gem.add_runtime_dependency('thin')
31
+ gem.add_runtime_dependency('thin', ["= 1.5.1"])
32
32
  gem.add_runtime_dependency('sinatra', ["~> 1.3.3"])
33
33
  gem.add_runtime_dependency('sinatra-websocket', ["~> 0.2.1"])
34
34
  end
@@ -2,14 +2,16 @@
2
2
  module Junkie
3
3
 
4
4
  require 'sindex'
5
+ require 'securerandom'
5
6
 
6
7
  class Episode
7
- attr_reader :id, :series, :found_at, :link
8
- attr_accessor :description, :status, :pid
8
+ attr_reader :uuid, :id, :series, :found_at
9
+ attr_accessor :description, :status, :pid, :links
9
10
 
10
- def initialize(series, link, description=nil)
11
+ def initialize(series, links, description=nil)
12
+ @uuid = SecureRandom.uuid
11
13
  @series = series
12
- @link = link
14
+ @links = links
13
15
  @found_at = DateTime.now
14
16
  @description = description
15
17
  @status = :found
@@ -20,6 +22,18 @@ module Junkie
20
22
  "%s (%s)" % [ @series, episode_identifier ]
21
23
  end
22
24
 
25
+ def to_hash
26
+ {
27
+ uuid: @uuid,
28
+ id: @id,
29
+ series: @series,
30
+ links: @links,
31
+ status: @status,
32
+ found_at: @found_at,
33
+ description: @description
34
+ }
35
+ end
36
+
23
37
  private
24
38
 
25
39
  def episode_identifier
@@ -65,8 +65,8 @@ module Junkie
65
65
  next
66
66
  end
67
67
 
68
- episode = Junkie::Episode.new(
69
- series, selected_link, link_data[:episodedata])
68
+ episode = Junkie::Episode.new(series, [selected_link], link_data[:episodedata])
69
+ episode.status = :encrypted
70
70
  episodes << episode
71
71
  end
72
72
  end
@@ -0,0 +1,28 @@
1
+
2
+ module Junkie
3
+ module Push
4
+
5
+ class Endpoint
6
+ include Log, Config
7
+
8
+ DEFAULT_CONFIG = {
9
+ gcm_app_key: '',
10
+ }
11
+
12
+ def initialize(channels)
13
+
14
+ channels[:push_registration].subscribe do |reg|
15
+ type, regid = reg
16
+
17
+ puts "Add registration %s=%s" % [type, regid]
18
+ end
19
+
20
+ channels[:push_episode_count].subscribe do |count|
21
+ puts "Count of encrypted episode links: %d" % [count]
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -31,7 +31,7 @@ module Junkie
31
31
  @should_stat_queued_episodes = false
32
32
 
33
33
  @channels[:episodes].subscribe do |episode|
34
- next unless episode.status == :found
34
+ next unless episode.status == :decrypted
35
35
 
36
36
  log.info("Got episode from Channel: #{episode}")
37
37
  @found_episodes.push(episode)
@@ -83,8 +83,7 @@ module Junkie
83
83
 
84
84
  package = "%s@%s" % [ episode.id, episode.series ]
85
85
 
86
- pid = @api.call(:addPackage,
87
- { name: package, links: [episode.link] })
86
+ pid = @api.call(:addPackage, {name: package, links: episode.links })
88
87
 
89
88
  episode.pid = pid
90
89
 
@@ -5,6 +5,7 @@ require 'eventmachine'
5
5
  require 'fiber'
6
6
  require 'yaml'
7
7
  require 'junkie'
8
+ require 'junkie/push/endpoint'
8
9
  require 'junkie/pyload/api'
9
10
  require 'junkie/pyload/observer'
10
11
  require 'junkie/errors'
@@ -20,21 +21,24 @@ module Junkie
20
21
  :episode_search_refresh => 15, # in minutes
21
22
  }
22
23
 
23
-
24
24
  def initialize
25
25
  @config = Config.get_config(self)
26
26
 
27
27
  log.info("Starting Junkie #{Junkie::VERSION}")
28
28
 
29
29
  @channels = {
30
+ encrypted: EM::Channel.new,
30
31
  episodes: EM::Channel.new,
31
32
  notifications: EM::Channel.new,
32
33
  info: EM::Channel.new,
34
+ push_episode_count: EM::Channel.new,
35
+ push_registration: EM::Channel.new,
33
36
  }
34
37
 
35
38
  @pyload_observer = Junkie::Pyload::Observer.new(@channels)
36
39
  @twitter_notification = Junkie::Notification::Twitter.new(@channels)
37
40
  @dumper = Junkie::Notification::Dumper.new(@channels)
41
+ @push_endpoint = Junkie::Push::Endpoint.new(@channels)
38
42
 
39
43
  @found_episodes = Hash.new
40
44
  build_procs # has to be called here
@@ -98,7 +102,7 @@ module Junkie
98
102
  if not @found_episodes.has_key? identifier
99
103
  log.info("Found new episode '#{episode}'")
100
104
 
101
- @channels[:episodes].push(episode)
105
+ @channels[:encrypted].push(episode)
102
106
  @found_episodes[identifier] = episode
103
107
  end
104
108
  end
@@ -1,3 +1,3 @@
1
1
  module Junkie
2
- VERSION = "0.0.15"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -25,6 +25,8 @@ module Junkie
25
25
 
26
26
  @@stats = Hash.new
27
27
 
28
+ @@encrypted_episodes = Hash.new
29
+
28
30
  # every connected client connects to the following channel, so infos
29
31
  # pushed to this channel are transmitted to the clients
30
32
  @@ws_channel = EM::Channel.new
@@ -36,9 +38,19 @@ module Junkie
36
38
  @@ws_channel.push(info)
37
39
  end
38
40
 
41
+ # get new encrypted episode links
42
+ @@channels[:encrypted].subscribe do |episode|
43
+ @@encrypted_episodes[episode.uuid] = episode
44
+ publish_encrypted_count
45
+ end
46
+
39
47
  run!
40
48
  end
41
49
 
50
+ def self.publish_encrypted_count
51
+ @@channels[:push_episode_count].push(@@encrypted_episodes.length)
52
+ end
53
+
42
54
  get '/' do
43
55
  if !request.websocket?
44
56
  @junkie_version = Junkie::VERSION
@@ -65,6 +77,41 @@ module Junkie
65
77
  end
66
78
  end
67
79
  end
80
+
81
+ get '/links/encrypted' do
82
+ content_type :json
83
+ @@encrypted_episodes.values.map {|e| e.to_hash }.to_json
84
+ end
85
+
86
+ post '/links/decrypt/:uuid' do
87
+ uuid = params["uuid"]
88
+ decrypted_links = JSON.parse(request.body.read).fetch("links") { [] }
89
+
90
+ if @@encrypted_episodes.has_key?(uuid) and !decrypted_links.empty?
91
+ episode = @@encrypted_episodes.delete(uuid)
92
+ episode.status = :decrypted
93
+ episode.links = decrypted_links
94
+
95
+ @@channels[:episodes].push(episode)
96
+ Interface.publish_encrypted_count
97
+
98
+ status 201
99
+ decrypted_links.to_json
100
+ else
101
+ status 404
102
+ end
103
+ end
104
+
105
+ post "/app/:service" do
106
+ registration_id = JSON.parse(request.body.read).fetch('regid') { nil }
107
+
108
+ if params['service'] != 'gcm' or registration_id == nil
109
+ status 404
110
+ else
111
+ @@channels[:push_registration].push([:gcm, registration_id])
112
+ status 201
113
+ end
114
+ end
68
115
  end
69
116
  end
70
117
  end
data/lib/junkie.rb CHANGED
@@ -6,6 +6,7 @@ require 'junkie/reactor'
6
6
  require 'junkie/errors'
7
7
  require 'junkie/helper'
8
8
  require 'junkie/patched/sjunkieex'
9
+ require 'junkie/push/endpoint'
9
10
  require 'junkie/pyload/api'
10
11
  require 'junkie/pyload/observer'
11
12
  require 'junkie/notification/twitter'
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junkie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Böhm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: em-http-request
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yajl-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashconfig
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.0.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.0.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: serienrenamer
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
- version: 0.0.1
89
+ version: 0.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
- version: 0.0.1
96
+ version: 0.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sjunkieex
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.0.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.0.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sindex
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.1
117
+ version: 0.2.5
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.1
124
+ version: 0.2.5
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: logging
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.8.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.8.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: twitter
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: 4.4.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: 4.4.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: thin
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 1.5.1
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.5.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: sinatra
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ~>
172
172
  - !ruby/object:Gem::Version
173
173
  version: 1.3.3
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ~>
179
179
  - !ruby/object:Gem::Version
180
180
  version: 1.3.3
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: sinatra-websocket
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - "~>"
185
+ - - ~>
186
186
  - !ruby/object:Gem::Version
187
187
  version: 0.2.1
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - "~>"
192
+ - - ~>
193
193
  - !ruby/object:Gem::Version
194
194
  version: 0.2.1
195
195
  description: TV series management application
@@ -200,9 +200,9 @@ executables:
200
200
  extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
- - ".gitignore"
204
- - ".rspec"
205
- - ".travis.yml"
203
+ - .gitignore
204
+ - .rspec
205
+ - .travis.yml
206
206
  - Gemfile
207
207
  - LICENSE.txt
208
208
  - README.md
@@ -218,6 +218,7 @@ files:
218
218
  - lib/junkie/notification/dumper.rb
219
219
  - lib/junkie/notification/twitter.rb
220
220
  - lib/junkie/patched/sjunkieex.rb
221
+ - lib/junkie/push/endpoint.rb
221
222
  - lib/junkie/pyload/api.rb
222
223
  - lib/junkie/pyload/observer.rb
223
224
  - lib/junkie/reactor.rb
@@ -240,17 +241,17 @@ require_paths:
240
241
  - lib
241
242
  required_ruby_version: !ruby/object:Gem::Requirement
242
243
  requirements:
243
- - - ">="
244
+ - - '>='
244
245
  - !ruby/object:Gem::Version
245
246
  version: 1.9.3
246
247
  required_rubygems_version: !ruby/object:Gem::Requirement
247
248
  requirements:
248
- - - ">="
249
+ - - '>='
249
250
  - !ruby/object:Gem::Version
250
251
  version: '0'
251
252
  requirements: []
252
253
  rubyforge_project:
253
- rubygems_version: 2.2.0
254
+ rubygems_version: 2.0.14
254
255
  signing_key:
255
256
  specification_version: 4
256
257
  summary: TV series managament tool that does all the work you have with your series.