crunchyroll 0.8 → 0.9

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: 9fc2673670e9b67f233b9e1b8a7226c538d02379
4
- data.tar.gz: 70cce56c3d67c297eb2ae86b6aa0d48dd225f23d
3
+ metadata.gz: 65f79e059e076d52d813500b1e8dbb70f607fa8f
4
+ data.tar.gz: 27e5a1996a1a34dc19a9a1a4716cd6c06cdd7fa0
5
5
  SHA512:
6
- metadata.gz: a13a71bc0b8a592177463162272d1e11d1f0c466ea528bba88b9dec1096c952f459345f6ea2c9a1455ff416413ecc656a4890218a007749adcbe1c97003043ea
7
- data.tar.gz: 0cc678fe9c5635449bba7a8f192dbf2ae0dbe9a68d0ce87f531d83df7f5d845e1b3aac029ae961d2b476e866fb2d3483082c876ca958b062609ea80237ab60a2
6
+ metadata.gz: 085f76901735aa8ebb2638b286296d974f4f67c030c7ff73b4702d79ca8ef9ccf349a5e49a2fdfdef8cb3e1bb96a00708524f48b30d6af902b868e0f0826177e
7
+ data.tar.gz: e46bc05c6705405a9905df1bbd70f8eeab846b97aded34d230587d4054887edbd8f4453e09afa4f9644931beec533c8cc72d443512c625684f2369591afc4a5b
@@ -12,9 +12,9 @@
12
12
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
13
  ##
14
14
 
15
- require 'date'
16
15
  require 'open-uri'
17
16
  require 'nokogiri'
17
+ require 'active_support/time'
18
18
  require 'time_difference'
19
19
  require 'chronic'
20
20
 
@@ -12,10 +12,14 @@
12
12
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
13
  ##
14
14
 
15
+ using Utils
16
+ Time.zone = 'MST'
17
+ Chronic.time_class = Time.zone
18
+
15
19
  module Crunchyroll
16
20
  class << self
17
21
 
18
- def find(series, time_diff = 8)
22
+ def find(series, time_zone = 'Rome')
19
23
  url = ''
20
24
  title = ''
21
25
  cr = 'http://www.iamalittlekitty.info/index.php?q=aHR0cDovL3d3dy5jcnVuY2h5cm9sbC5jb20vbGluZXVw&hl=3ed'
@@ -30,8 +34,8 @@ class << self
30
34
 
31
35
  air = Nokogiri::HTML(open(url)).xpath('//ul[@id="sidebar_elements"]/li').select { |e| e.at_xpath('.//p[@class="strong"]') }[0].text
32
36
  day_literal = air.split('Simulcast on ')[1].split(' ')[0][0..-2]
33
- date = Time.parse(air.format_cr_date).add_hours time_diff
34
- date = Chronic.parse("this #{day_literal} at #{date.hour}:#{date.min}")
37
+ date = Time.parse(air.format_cr_date)
38
+ date = Chronic.parse("this #{day_literal} at #{date.hour}:#{date.min}").in_time_zone time_zone
35
39
 
36
40
  {
37
41
  :title => title,
@@ -44,13 +48,14 @@ class << self
44
48
  end
45
49
  alias_method :get, :find
46
50
 
47
- def today(time_diff = 8)
51
+ def today(time_zone = 'Rome')
48
52
  url = 'http://horriblesubs.info/release-schedule/'
53
+
49
54
  [].tap { |releases|
50
55
  Nokogiri::HTML(open(url)).xpath('//div[@class="today-releases"]/div[@class="series-name"]').each { |r|
51
56
  title = r.at_xpath('.//child::text()').to_s.squeeze(' ')
52
57
  time = r.at_xpath('.//span').text
53
- date = Time.parse(time).add_hours time_diff
58
+ date = Chronic.parse(time).in_time_zone time_zone
54
59
 
55
60
  releases << {
56
61
  :title => title,
@@ -12,46 +12,44 @@
12
12
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
13
13
  ##
14
14
 
15
- class Time
16
- def left(end_time)
17
- diff = TimeDifference.between(self, end_time).in_general
18
-
19
- secs = diff[:seconds].to_i
20
- mins = diff[:minutes].to_i
21
- hours = diff[:hours ].to_i
22
- days = diff[:days ].to_i
15
+ module Utils
16
+ refine Time do
17
+ def left(end_time)
18
+ diff = TimeDifference.between(self, end_time).in_general
19
+
20
+ secs = diff[:seconds].to_i
21
+ mins = diff[:minutes].to_i
22
+ hours = diff[:hours ].to_i
23
+ days = diff[:days ].to_i
23
24
 
24
- if days > 0
25
- "#{days} days, #{hours} hours, #{mins} minutes and #{secs} seconds"
26
- elsif hours > 0
27
- "#{hours} hours, #{mins} minutes and #{secs} seconds"
28
- elsif mins > 0
29
- "#{mins} minutes and #{secs} seconds"
30
- elsif secs >= 0
31
- "#{secs} seconds"
25
+ if days > 0
26
+ "#{days} days, #{hours} hours, #{mins} minutes and #{secs} seconds"
27
+ elsif hours > 0
28
+ "#{hours} hours, #{mins} minutes and #{secs} seconds"
29
+ elsif mins > 0
30
+ "#{mins} minutes and #{secs} seconds"
31
+ elsif secs >= 0
32
+ "#{secs} seconds"
33
+ end
32
34
  end
33
35
  end
34
36
 
35
- def add_hours(n = 1)
36
- self + (n * 60 * 60)
37
- end
38
- end
39
-
40
- class String
41
- def to_24h
42
- DateTime.parse(self).strftime("%H:%M")
43
- end
37
+ refine String do
38
+ def to_24h
39
+ DateTime.parse(self).strftime("%H:%M")
40
+ end
44
41
 
45
- def format_cr_date
46
- s = ''
47
- self.split('Simulcast on ')[1][0..-5].split.each { |d| s += d.end_with?(?s) ? d[0..-2] : d; s += ' ' }
48
-
49
- am_pm = s.strip[-2..-1]
50
- s = s.strip[0..-3]
42
+ def format_cr_date
43
+ s = ''
44
+ self.split('Simulcast on ')[1][0..-5].split.each { |d| s += d.end_with?(?s) ? d[0..-2] : d; s += ' ' }
45
+
46
+ am_pm = s.strip[-2..-1]
47
+ s = s.strip[0..-3]
51
48
 
52
- day_time = s.split
53
- day = day_time.shift
54
- time = day_time.shift.to_24h
55
- return "#{day} #{time}"
49
+ day_time = s.split
50
+ day = day_time.shift
51
+ time = day_time.shift.to_24h
52
+ return "#{day} #{time}"
53
+ end
56
54
  end
57
55
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  module Crunchyroll
16
16
  def self.version
17
- '0.8'
17
+ '0.9'
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchyroll
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-09 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Find and get infos about series airing on Crunchyroll.
56
70
  email: webmaster@giovannicapuano.net
57
71
  executables: []