crunchyroll 0.3 → 0.4

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: 3ed78ad69da8c2cb9a37981150d109316ca0c183
4
- data.tar.gz: 14d8e9457489c24274960e156c7fc1bdae715682
3
+ metadata.gz: 889fa4d59436602c267f6c0246278c738ae542ff
4
+ data.tar.gz: 77c6f42a6f1eb22e721a5db458fb05ad190489a2
5
5
  SHA512:
6
- metadata.gz: c109d712be309f0b3cd951892c7e800a96e47be80b01a47a9b43b0f735d3b48227a63389f48a0adaf99fd16380d695861ab2b714161f2123fab5ddd5bc11ea22
7
- data.tar.gz: fdd2f27377adc2272686e9b5ae27c6809a94ae88b995f1219873ad0ef872f464002876526d845e2a08b92c8deca42ce8c9514bfac0e21c656c53baabbe89d1fd
6
+ metadata.gz: abf96a1ea2c6e59f8ceb12c355712697f8e59fd110f5b6b2c95eb64ea35dee55bc2bbc35324a2717996da34a0db4229138108b0fb13cc1aeccb4334eb2844aaa
7
+ data.tar.gz: 50e8a64348afc490abd4ff67ff75aa2b35dc8c28804c104da84824ae8d4ee2c6b0edd95d7d14926698f5d3903e08a5d7c057a0199c54ed6f8f8305ddf78bbae0
@@ -16,6 +16,7 @@ require 'date'
16
16
  require 'open-uri'
17
17
  require 'nokogiri'
18
18
  require 'time_difference'
19
+ require 'chronic'
19
20
 
20
21
  require 'crunchyroll/utils'
21
22
  require 'crunchyroll/crunchyroll'
@@ -1,6 +1,18 @@
1
+ ##
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # Everyone is permitted to copy and distribute verbatim or modified
6
+ # copies of this license document, and changing it is allowed as long
7
+ # as the name is changed.
8
+ #
9
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11
+ #
12
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
+ ##
1
14
  module Crunchyroll
2
15
  def self.find(series)
3
- begin
4
16
  url = ''
5
17
  title = ''
6
18
  cr = 'http://www.uswebproxy.com/index.php?q=aHR0cDovL3d3dy5jcnVuY2h5cm9sbC5jb20vbGluZXVw&hl=3ed'
@@ -16,18 +28,15 @@ module Crunchyroll
16
28
 
17
29
  air = Nokogiri::HTML(open(url)).xpath('//ul[@id="sidebar_elements"]/li')[1].xpath('.//p')[0].text
18
30
  day_literal = air.split('Simulcast on ')[1].split(' ')[0]
19
- date = Time.parse(air.split('Simulcast on ')[1]).date_of_next
31
+ date = Chronic.parse "this #{air.format_cr_date}"
20
32
 
21
33
  return {
22
34
  :title => title,
23
35
  :where => 'Crunchyroll',
24
36
  :day => day_literal,
25
- :hour => date.hour.fix,
26
- :min => date.min.fix,
27
- :left => date.time_left(Time.now)
37
+ :hour => date.hour.to_24h,
38
+ :min => date.min.to_24h,
39
+ :left => Time.now.left(date)
28
40
  }
29
- rescue
30
- return false
31
- end
32
41
  end
33
42
  end
@@ -11,10 +11,9 @@
11
11
  #
12
12
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
13
  ##
14
-
15
14
  class Time
16
- def time_left(start_time)
17
- diff = TimeDifference.between(start_time, self.add_day).in_general
15
+ def left(end_time)
16
+ diff = TimeDifference.between(self, end_time.add_hour(9).add_day).in_general
18
17
 
19
18
  secs = diff[:seconds].to_i
20
19
  mins = diff[:minutes].to_i
@@ -35,16 +34,28 @@ class Time
35
34
  def add_day(n = 1)
36
35
  self + (n * 24 * 60 * 60)
37
36
  end
38
-
39
- def date_of_next
40
- date = self + 9 / 24.0 # proxy is PST
41
- delta = date > Time.now ? 0 : 7
42
- date + delta
37
+
38
+ def add_hour(n = 1)
39
+ self + (n * 60)
43
40
  end
44
41
  end
45
42
 
46
43
  class Fixnum
47
- def fix
44
+ def to_24h
48
45
  self > 9 ? self.to_s : "0#{self}"
49
46
  end
47
+ end
48
+
49
+ class String
50
+ def format_cr_date
51
+ s = ''
52
+ self.split('Simulcast on ')[1][0..-5].split.each { |d| s += d.end_with?(?s) ? d[0..-2] : d; s += ' ' }
53
+ s = s.strip[0..-3]
54
+
55
+ day = s.split[0]
56
+ time = s.split[1].split(?:)
57
+ hours = time[0].strip.to_i
58
+ minutes = time[1]
59
+ return "#{day} #{hours + 12}:#{minutes}"
60
+ end
50
61
  end
@@ -11,9 +11,8 @@
11
11
  #
12
12
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
13
  ##
14
-
15
14
  module Crunchyroll
16
15
  def self.version
17
- '0.3'
16
+ '0.4'
18
17
  end
19
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchyroll
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: chronic
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Find and get infos about series airing on Crunchyroll.
42
56
  email: webmaster@giovannicapuano.net
43
57
  executables: []