shin 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shin/base.rb +3 -3
- data/lib/shin/play/hbonordic.rb +8 -24
- data/lib/shin/play/oppetarkiv.rb +26 -25
- data/lib/shin/play/tv4play.rb +35 -17
- data/lib/shin/play/viaplay.rb +111 -0
- data/lib/shin/play.rb +17 -12
- data/lib/shin/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a5f3a6975b8dea12e153fe170669bb3d00ea1e
|
4
|
+
data.tar.gz: b4e12a22bebf5a459fe3f78b49742e44aa5b461e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfbeb5d249674a31aacf3450d1d6ae17c5c7dc23e87d449032da2301ecae1524cc42d48dffd8c41f4cffac5cbaa968c7ad8d3f5a750b79ea01799248a8728af
|
7
|
+
data.tar.gz: 8e51485ab8478411f8e244a0eb84977ee4bbbf3cc9eee7dba005aa2ea24c07f0a13aff889415393ba8dfbfdb05f77f78fb1977e972bcd43e692d02389cc9ed26
|
data/lib/shin/base.rb
CHANGED
@@ -7,10 +7,10 @@ module Shin
|
|
7
7
|
self
|
8
8
|
end
|
9
9
|
|
10
|
-
def get(url)
|
11
|
-
response = self.class.get(url).parsed_response
|
10
|
+
def get(url, parameters={})
|
11
|
+
response = self.class.get(url, parameters).parsed_response
|
12
12
|
return [] unless response
|
13
13
|
response
|
14
14
|
end
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
data/lib/shin/play/hbonordic.rb
CHANGED
@@ -2,41 +2,25 @@
|
|
2
2
|
module Shin
|
3
3
|
module Play
|
4
4
|
class Hbonordic
|
5
|
-
|
5
|
+
|
6
6
|
def new
|
7
7
|
self
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# Category
|
11
11
|
def all(params={})
|
12
|
-
|
13
|
-
|
12
|
+
|
14
13
|
# Response
|
15
|
-
response = Base.get('
|
16
|
-
|
14
|
+
response = Base.get('https://api-hbon.hbo.clearleap.com/cloffice/client/web/browse/' + params[:id] + '?max=10000&offset=0&language=' + params[:language], {local_host: "188.165.139.194"})
|
15
|
+
|
17
16
|
# They place movies in a "entry" tag somehow
|
18
|
-
|
19
|
-
response.parsed_response['entry'].to_hashugar
|
20
|
-
else
|
21
|
-
response.parsed_response.to_hashugar
|
22
|
-
end
|
17
|
+
response.parsed_response["rss"]["channel"].to_hashugar
|
23
18
|
end
|
24
|
-
|
25
|
-
# Info
|
26
|
-
def info(params={})
|
27
|
-
raise NotValid, "Not a valid category. Please check again." unless ["movies", "series"].include?(params[:category])
|
28
|
-
|
29
|
-
# Response
|
30
|
-
response = Base.get('http://hbonordic.se/rest-services-hook/' + params[:category] + '/' + params[:id])
|
31
|
-
|
32
|
-
# Data
|
33
|
-
response.parsed_response.to_hashugar
|
34
|
-
end
|
35
|
-
|
19
|
+
|
36
20
|
# Errors
|
37
21
|
class NotValid < StandardError; end
|
38
22
|
class MissingArgument < StandardError; end
|
39
23
|
class HTTPError < StandardError; end
|
40
24
|
end
|
41
25
|
end
|
42
|
-
end
|
26
|
+
end
|
data/lib/shin/play/oppetarkiv.rb
CHANGED
@@ -5,41 +5,42 @@ require 'time'
|
|
5
5
|
module Shin
|
6
6
|
module Play
|
7
7
|
class Oppetarkiv
|
8
|
-
|
8
|
+
|
9
9
|
def new
|
10
10
|
self
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
# Episodes
|
14
14
|
def episodes(params={})
|
15
15
|
raise MissingArgument, "You are missing the argument 'slug' which is required to use this source." unless params[:slug] != ""
|
16
|
-
|
16
|
+
|
17
17
|
# What to return
|
18
18
|
array = {title: nil, episodes: []}
|
19
|
-
|
19
|
+
|
20
20
|
total_pages = 999
|
21
21
|
(1..total_pages).each do |page_num|
|
22
22
|
# Response
|
23
23
|
response = Base.get('http://www.oppetarkiv.se/etikett/titel/' + params[:slug].to_s + '/?sida=' + page_num.to_s + '&sort=tid_stigande')
|
24
|
+
puts 'http://www.oppetarkiv.se/etikett/titel/' + params[:slug].to_s + '/?sida=' + page_num.to_s + '&sort=tid_stigande'
|
24
25
|
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
25
|
-
|
26
|
+
|
26
27
|
# Nokogiri parse
|
27
28
|
@main_noko = Nokogiri::HTML response.body rescue nil
|
28
|
-
|
29
|
+
|
29
30
|
# Can't be nil
|
30
31
|
if @main_noko != nil
|
31
32
|
# Title
|
32
33
|
array[:title] = @main_noko.css('span.svt-heading-l').text.strip rescue nil
|
33
|
-
|
34
|
+
|
34
35
|
# Episodes
|
35
|
-
@main_noko.css('div.svtoa-js-searchlist > article').map do |e|
|
36
|
+
@main_noko.css('div.svtoa-js-searchlist-episodes > article').map do |e|
|
36
37
|
@video_id = e.css('a')[0]['href'][/\/video\/(\d+)\//, 1].to_i rescue nil
|
37
38
|
@url = e.css('a')[0]['href'] rescue nil
|
38
|
-
@season = e.css('
|
39
|
-
@episode = e.css('
|
40
|
-
@of_episode = e.css('
|
41
|
-
@image = e.css('img.
|
42
|
-
|
39
|
+
@season = e.css('h1.svt-text-margin-small').text[/S.song\s+(\d+)/, 1].to_i rescue nil
|
40
|
+
@episode = e.css('h2.svt-heading-xxs.svt-text-margin-medium').text[/Avsnitt\s+(\d+)/, 1].to_i rescue nil
|
41
|
+
@of_episode = e.css('h2.svt-heading-xxs.svt-text-margin-medium').text[/Avsnitt\s+(\d+)\s+av\s+(\d+)/, 2].to_i rescue nil
|
42
|
+
@image = e.css('noscript > img.oaImg')[0]['src'].gsub("ALTERNATES/medium", "ALTERNATES/extralarge") rescue nil
|
43
|
+
|
43
44
|
# Parse published_to
|
44
45
|
if e.css('time') != nil and e.css('time') != "" and pat = e.css('time')[0]['datetime']
|
45
46
|
@published_on = Time.parse(pat) rescue nil
|
@@ -47,36 +48,36 @@ module Shin
|
|
47
48
|
|
48
49
|
# No episode info? Possible a subtitle
|
49
50
|
if @season < 1 and @episode < 1
|
50
|
-
@subtitle = e.css('
|
51
|
+
@subtitle = e.css('h2.svt-heading-xxs.svt-text-margin-medium > a')[0]['title'].strip
|
51
52
|
else
|
52
|
-
@subtitle = e.css('
|
53
|
+
@subtitle = e.css('h2.svt-heading-xxs.svt-text-margin-medium > a')[0]['title'].gsub("Avsnitt " + @episode.to_s + ' av ' + @of_episode.to_s + ':', '').gsub("Avsnitt " + @episode.to_s + ' av ' + @of_episode.to_s, '').strip
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
array[:episodes] << {id: @video_id, subtitle: @subtitle, image: @image, season: @season, episode: @episode, of_episodes: @of_episode, url: @url, published_on: @published_on}
|
56
|
-
|
57
|
+
|
57
58
|
end
|
58
59
|
|
59
60
|
# No more pages, break.
|
60
|
-
if @main_noko.css('
|
61
|
+
if @main_noko.css('.svtoa-js-search-step-button > span > span.svt_icon--caret-down').to_s == ""
|
61
62
|
break
|
62
63
|
end
|
63
64
|
else
|
64
65
|
raise NotValid, "Nokogiri failed to parse the HTML."
|
65
66
|
end
|
66
67
|
end
|
67
|
-
|
68
|
+
|
68
69
|
array.to_hashugar
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
# Programs
|
72
73
|
def programs
|
73
74
|
# Response
|
74
75
|
response = Base.get('http://www.oppetarkiv.se/kategori/titel')
|
75
76
|
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
76
|
-
|
77
|
+
|
77
78
|
# Nokogiri parse
|
78
79
|
@main_noko = Nokogiri::HTML response.body rescue nil
|
79
|
-
|
80
|
+
|
80
81
|
# Foreach programs
|
81
82
|
@array = []
|
82
83
|
if @main_noko != nil
|
@@ -89,12 +90,12 @@ module Shin
|
|
89
90
|
|
90
91
|
@array.to_hashugar
|
91
92
|
end
|
92
|
-
|
93
|
-
|
93
|
+
|
94
|
+
|
94
95
|
# Errors
|
95
96
|
class MissingArgument < StandardError; end
|
96
97
|
class HTTPError < StandardError; end
|
97
98
|
class NotValid < StandardError; end
|
98
99
|
end
|
99
100
|
end
|
100
|
-
end
|
101
|
+
end
|
data/lib/shin/play/tv4play.rb
CHANGED
@@ -2,60 +2,60 @@
|
|
2
2
|
module Shin
|
3
3
|
module Play
|
4
4
|
class Tv4play
|
5
|
-
|
5
|
+
|
6
6
|
def new
|
7
7
|
self
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# Programs
|
11
11
|
def programs
|
12
12
|
# Response
|
13
13
|
response = Base.get('http://webapi.tv4play.se/play/programs?per_page=900&page=1')
|
14
14
|
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
15
|
-
|
15
|
+
|
16
16
|
# Data
|
17
17
|
data = Oj.load(response.body) rescue nil
|
18
|
-
|
18
|
+
|
19
19
|
# Can't be nil
|
20
20
|
if data != nil
|
21
21
|
data['results'].to_hashugar
|
22
22
|
else
|
23
23
|
raise NotValid, "Couldn't parse the JSON"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# Videos
|
29
29
|
def videos(params={})
|
30
30
|
raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != ""
|
31
|
-
|
31
|
+
|
32
32
|
# Response
|
33
33
|
response = Base.get('http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&per_page=99999&node_nids=' + params[:id].to_s)
|
34
34
|
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
35
|
-
|
35
|
+
|
36
36
|
# Data
|
37
37
|
data = Oj.load(response.body) rescue nil
|
38
|
-
|
38
|
+
|
39
39
|
# Can't be nil
|
40
40
|
if data != nil
|
41
41
|
data['results'].to_hashugar
|
42
42
|
else
|
43
43
|
raise NotValid, "Couldn't parse the JSON"
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# Video
|
49
49
|
def video(params={})
|
50
50
|
raise MissingArgument, "You are missing the argument 'id' which is required to use this source." unless params[:id] != ""
|
51
|
-
|
51
|
+
|
52
52
|
# Response
|
53
53
|
response = Base.get('http://webapi.tv4play.se/play/video_assets?id=' + params[:id].to_s)
|
54
54
|
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
55
|
-
|
55
|
+
|
56
56
|
# Data
|
57
57
|
data = Oj.load(response.body) rescue nil
|
58
|
-
|
58
|
+
|
59
59
|
# Can't be nil
|
60
60
|
if data != nil
|
61
61
|
if data['total_hits'] == 0
|
@@ -63,16 +63,34 @@ module Shin
|
|
63
63
|
else
|
64
64
|
data['results'].first.to_hashugar
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
else
|
68
68
|
raise NotValid, "Couldn't parse the JSON"
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
|
+
# Movies
|
73
|
+
def movies
|
74
|
+
# Response
|
75
|
+
response = Base.get('http://webapi.tv4play.se/play/movie_assets?platform=web&start=0&rows=9999')
|
76
|
+
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
77
|
+
|
78
|
+
# Data
|
79
|
+
data = Oj.load(response.body) rescue nil
|
80
|
+
|
81
|
+
# Can't be nil
|
82
|
+
if data != nil
|
83
|
+
data['results'].to_hashugar
|
84
|
+
else
|
85
|
+
raise NotValid, "Couldn't parse the JSON"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
72
90
|
# Errors
|
73
91
|
class NotValid < StandardError; end
|
74
92
|
class MissingArgument < StandardError; end
|
75
93
|
class HTTPError < StandardError; end
|
76
94
|
end
|
77
95
|
end
|
78
|
-
end
|
96
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
## Viaplay have an API but it isn't for public use
|
2
|
+
module Shin
|
3
|
+
module Play
|
4
|
+
class Viaplay
|
5
|
+
|
6
|
+
def new
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
# Fix these before running
|
11
|
+
def before(params={})
|
12
|
+
raise MissingArgument, "You are missing the argument 'viaplay_country' which is required to use this source." unless Shin.get[:viaplay_country] != nil
|
13
|
+
|
14
|
+
"https://content.viaplay." + Shin.get[:viaplay_country] + "/pcdash-" + Shin.get[:viaplay_country] + "/"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Series
|
18
|
+
def series(params={})
|
19
|
+
# domain
|
20
|
+
domain = before()
|
21
|
+
country = Shin.get[:viaplay_country]
|
22
|
+
|
23
|
+
# Translated shit
|
24
|
+
type = "kaikki" if country == "fi"
|
25
|
+
type = "alle" if country == "dk" or country == "no"
|
26
|
+
type = "samtliga" if country == "se"
|
27
|
+
|
28
|
+
# URLs
|
29
|
+
if params[:page] != nil
|
30
|
+
id = type + "?pageNumber=" + params[:page].to_s + "&sort=recently_added"
|
31
|
+
elsif params[:season] != nil
|
32
|
+
id = params[:id] + "?seasonNumber=" + params[:season].to_s
|
33
|
+
elsif params[:id] != nil
|
34
|
+
id = params[:id].to_s
|
35
|
+
else
|
36
|
+
id = type + "?sort=recently_added"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Response
|
40
|
+
if country == "fi"
|
41
|
+
response = Base.get(domain + 'sarjat/' + id)
|
42
|
+
else
|
43
|
+
response = Base.get(domain + 'serier/' + id)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
48
|
+
|
49
|
+
# Data
|
50
|
+
data = Oj.load(response.body) rescue nil
|
51
|
+
|
52
|
+
# Can't be nil
|
53
|
+
if data != nil
|
54
|
+
data['_embedded']['viaplay:blocks'].to_hashugar
|
55
|
+
else
|
56
|
+
raise NotValid, "Couldn't parse the JSON"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# Movies
|
62
|
+
def movies(params={})
|
63
|
+
# domain
|
64
|
+
domain = before()
|
65
|
+
country = Shin.get[:viaplay_country]
|
66
|
+
|
67
|
+
# Translated shit
|
68
|
+
type = "kaikki" if country == "fi"
|
69
|
+
type = "alle" if country == "dk" or country == "no"
|
70
|
+
type = "samtliga" if country == "se"
|
71
|
+
|
72
|
+
if params[:page] != nil
|
73
|
+
id = type + "?pageNumber=" + params[:page].to_s + "&sort=recently_added"
|
74
|
+
elsif params[:id] != nil
|
75
|
+
id = params[:id].to_s
|
76
|
+
else
|
77
|
+
id = type + "?sort=recently_added"
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# Response
|
83
|
+
if country == "fi"
|
84
|
+
response = Base.get(domain + 'leffat/' + id)
|
85
|
+
elsif country == "no"
|
86
|
+
response = Base.get(domain + 'filmer/' + id)
|
87
|
+
else
|
88
|
+
response = Base.get(domain + 'film/' + id)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200
|
93
|
+
|
94
|
+
# Data
|
95
|
+
data = Oj.load(response.body) rescue nil
|
96
|
+
|
97
|
+
# Can't be nil
|
98
|
+
if data != nil
|
99
|
+
data['_embedded']['viaplay:blocks'].to_hashugar
|
100
|
+
else
|
101
|
+
raise NotValid, "Couldn't parse the JSON"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Errors
|
106
|
+
class NotValid < StandardError; end
|
107
|
+
class MissingArgument < StandardError; end
|
108
|
+
class HTTPError < StandardError; end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/lib/shin/play.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'play/oppetarkiv'
|
|
4
4
|
require_relative 'play/tv4play'
|
5
5
|
require_relative 'play/urplay'
|
6
6
|
require_relative 'play/sbstv'
|
7
|
-
|
7
|
+
require_relative 'play/viaplay'
|
8
8
|
#require_relative 'play/netflix'
|
9
9
|
require_relative 'play/viasat'
|
10
10
|
#require_relative 'play/headweb'
|
@@ -24,52 +24,57 @@ module Shin
|
|
24
24
|
def new
|
25
25
|
self
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# SVTPLAY.SE (SWEDISH CONTENT)
|
29
29
|
def svtplay
|
30
30
|
@svtplay ||= Svtplay.new
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
# VIKI.COM (ASIAN CONTENT)
|
34
34
|
def viki
|
35
35
|
@viki ||= Viki.new
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# OPPETARKIV.SE (SWEDISH CONTENT)
|
39
39
|
def oppetarkiv
|
40
40
|
@oppetarkiv ||= Oppetarkiv.new
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
# URPLAY.SE (SWEDISH CONTENT)
|
44
44
|
def urplay
|
45
45
|
@urplay ||= Urplay.new
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# TV4PLAY.SE (SWEDISH CONTENT)
|
49
49
|
def tv4play
|
50
50
|
@tv4play ||= Tv4play.new
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
# SBSTV (K5, K9, K11) (SWEDISH CONTENT)
|
54
54
|
def sbstv
|
55
55
|
@sbstv ||= Sbstv.new
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Viasat (TV3 etc) (NORDIC CONTENT)
|
59
59
|
def viasat
|
60
60
|
@viasat ||= Viasat.new
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
|
+
# Viaplay (NORDIC CONTENT)
|
64
|
+
def viaplay
|
65
|
+
@viaplay ||= Viaplay.new
|
66
|
+
end
|
67
|
+
|
63
68
|
# HBO Nordic (NORDIC CONTENT)
|
64
69
|
def hbonordic
|
65
70
|
@hbonordic ||= Hbonordic.new
|
66
71
|
end
|
67
|
-
|
72
|
+
|
68
73
|
# Apple iTunes (WORLDWIDE CONTENT)
|
69
74
|
def apple
|
70
75
|
@apple ||= Apple.new
|
71
76
|
end
|
72
|
-
|
77
|
+
|
73
78
|
end
|
74
79
|
end
|
75
|
-
end
|
80
|
+
end
|
data/lib/shin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Nylen
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/shin/play/svtplay.rb
|
110
110
|
- lib/shin/play/tv4play.rb
|
111
111
|
- lib/shin/play/urplay.rb
|
112
|
+
- lib/shin/play/viaplay.rb
|
112
113
|
- lib/shin/play/viasat.rb
|
113
114
|
- lib/shin/play/viki.rb
|
114
115
|
- lib/shin/reviews.rb
|