kijkwijzer 0.1.5 → 0.2.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
  SHA256:
3
- metadata.gz: af0948d919a2baa520ea0fbe6850cd8a74b241a9e00bad76064d3aa723d0d8b4
4
- data.tar.gz: 665557ad474bb0c71d7e747ea4af1e9a0d7a8271e9d6ca3984b771bbe3af43df
3
+ metadata.gz: 364e7dcc3d6ce2901ccfbefe6d8cac8afc871b1a7d8618f65d2c04ee36fb53f1
4
+ data.tar.gz: c1fdd1b56dc80a0aac1f6f078fc35a7c57e766cabe78ebc2fa4377c381663b58
5
5
  SHA512:
6
- metadata.gz: 8e6967d69d49728712381248768c622906b4450471f73c78b62462d9452f6b2956fe407e418ad3dec4317d9ee52ff6dbcc1764f74444c92508c58d7447641aa1
7
- data.tar.gz: 7fcde1ba4a440bf813418437eb8d65374d72528e73be52f017d123e37ea76583bed348b54521dbe3512cc1c631310d9151c0e1d33b0fe76361a790534856f601
6
+ metadata.gz: 49de5dd1b013871fcc717f4ab685fb6def12d9ae75bf765b3d7152385f195befce5f0411be70da23ceb8c40fdf577dab88908ca7d9f44250e95f8e4afd30c2e9
7
+ data.tar.gz: ea041fe6040577be23c04deb7f5a48e8f85de0e7e2ffb0710183fd9bd70aac76cb789dd155b558987caa6a7b692f496e2b9c4195c5672f84a08ba2d29ab76a62
data/README.md CHANGED
@@ -56,6 +56,16 @@ Then to display the movie results use the view helper `render_kijkwijzers`:
56
56
 
57
57
  Make sure you format the icons properly, otherwise you'll get huge icons ... I believe I've added plenty of classes for easy styling using css.
58
58
 
59
+ ## Changelog
60
+
61
+ 0.2.0 May 4, 2022
62
+ Updated results scraping to their pudated HTML format
63
+
64
+ 0.1.5 November 16, 2021
65
+ update dependencies / loosen dev requirements
66
+
67
+
68
+
59
69
  ## Development
60
70
 
61
71
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -33,13 +33,17 @@ module Kijkwijzer
33
33
  class << self
34
34
  def new_from_nokogiri_result_fragment nokogiri_result_fragment
35
35
  r = self.new
36
- r.title = nokogiri_result_fragment.css('b').text
37
- production_type_match = nokogiri_result_fragment.text.match(/Productietype\:\s(.*)\.(\sProductie)/)
38
- production_year_match = nokogiri_result_fragment.text.match(/\sProductiejaar\:\s(\d\d\d\d)\.\s/)
39
- r.year = production_year_match[1].to_i if production_year_match
40
- r.production_type = production_type_match[1] if production_type_match
41
- r.ratings = nokogiri_result_fragment.css("img").collect{|a| a.attr("src").match(/\/upload\/pictogrammen\/\d*_\d*_(.*)\.png/)[1]}
42
- return r
36
+ r.title = nokogiri_result_fragment.css('.c-search__title').text
37
+ production_type_year_match = nokogiri_result_fragment.css('.c-search__text').text.match(/\A\s*(.*)\s*\((\d\d\d\d)\)\s*$/)
38
+ if production_type_year_match
39
+ r.year = production_type_year_match[2].to_i if production_type_year_match[2]
40
+ r.production_type = production_type_year_match[1].strip if production_type_year_match[1]
41
+ r.ratings = nokogiri_result_fragment.css(".c-search__marks .c-search__mark").collect do |a|
42
+ class_fragment = a.attr("class").match(/\Ac-search__mark\sc-search__mark--(.*)$/)[1]
43
+ Kijkwijzer::POSSIBLE_RATINGS.find{|a| a[:nl_key] == class_fragment}&.[](:value)
44
+ end.compact
45
+ return r
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -1,3 +1,3 @@
1
1
  module Kijkwijzer
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/kijkwijzer.rb CHANGED
@@ -7,24 +7,24 @@ require 'kijkwijzer/railtie' if defined?(Rails)
7
7
 
8
8
  module Kijkwijzer
9
9
  POSSIBLE_RATINGS = [
10
- {name: "Alle leeftijden", value: "al", code: "al"},
11
- {name: "6 jaar en ouder", value: "6", code: "6"},
12
- {name: "9 jaar en ouder", value: "9", code: "9"},
13
- {name: "12 jaar en ouder", value: "12", code: "12"},
14
- {name: "16 jaar en ouder", value: "16", code: "16"},
15
- {name: "Geweld", value: "violence", code: "g"},
16
- {name: "Angst", value: "scary", code: "a"},
17
- {name: "Seks", value: "sex", code: "s"},
18
- {name: "Discriminatie", value: "discrimination", code: "d"},
19
- {name: "Drugs en/of alcoholmisbruik", value: "drugs", code: "h"},
20
- {name: "Grof taalgebruik", value: "language", code: "t"}
10
+ {nl_key: "alle-leeftijden", name: "Alle leeftijden", value: "al", code: "al"},
11
+ {nl_key: "leeftijd-6", name: "6 jaar en ouder", value: "6", code: "6"},
12
+ {nl_key: "leeftijd-9", name: "9 jaar en ouder", value: "9", code: "9"},
13
+ {nl_key: "leeftijd-12", name: "12 jaar en ouder", value: "12", code: "12"},
14
+ {nl_key: "leeftijd-16", name: "16 jaar en ouder", value: "16", code: "16"},
15
+ {nl_key: "geweld", name: "Geweld", value: "violence", code: "g"},
16
+ {nl_key: "angst", name: "Angst", value: "scary", code: "a"},
17
+ {nl_key: "seks", name: "Seks", value: "sex", code: "s"},
18
+ {nl_key: "discriminatie", name: "Discriminatie", value: "discrimination", code: "d"},
19
+ {nl_key: "drugs", name: "Drugs en/of alcoholmisbruik", value: "drugs", code: "h"},
20
+ {nl_key: "grof-taalgebruik", name: "Grof taalgebruik", value: "language", code: "t"}
21
21
  ]
22
22
  class << self
23
23
  def search_url(search)
24
- "http://www.kijkwijzer.nl/index.php?id=3__i&searchfor=#{url_encode(search)}&tab=KIJKWIJZER"
24
+ "https://www.kijkwijzer.nl/zoeken/?query=#{url_encode(search)}&producties=0"
25
25
  end
26
26
  def get_content(search)
27
- Nokogiri::HTML(open(search_url(search)))
27
+ Nokogiri::HTML(URI::open(search_url(search)))
28
28
  end
29
29
 
30
30
  # Search the Kijkwijzer database
@@ -33,9 +33,9 @@ module Kijkwijzer
33
33
  def search(search, filter={})
34
34
  res = get_content(search)
35
35
  results = []
36
- res.css('.content_hok .nieuwsitem').each do |result|
36
+ res.css('.c-search__results .c-search__result').each do |result|
37
37
  r = Result.new_from_nokogiri_result_fragment(result)
38
- results << r if r.match_filter?(filter)
38
+ results << r if (r && r.match_filter?(filter))
39
39
  end
40
40
  results
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kijkwijzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Brouwers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri