crunchyroll 0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6726d4ad7dcfa61069707c606f48c27c240829b8
4
+ data.tar.gz: d4ca29e66c7b6fb8669f37f16436e998df53cd8b
5
+ SHA512:
6
+ metadata.gz: 08f6094f1a643b032ea1dc8a87e169be334e7bc5696a91a336ebcce15566cdf789c83d4a338abaa5f610d6f0c79ae9a315f64d9c3236c0706963f69044c76cfc
7
+ data.tar.gz: 8bab2f2bc7e6dbb2370df830283258b6f57bd3923d1e91013a1448193b4de6ebcdfb59ed251472ea2d6e71946eea642fccee0d3b0006c04977f6c8a39b55aad1
@@ -0,0 +1,22 @@
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
+ ##
14
+
15
+ require 'date'
16
+ require 'open-uri'
17
+ require 'nokogiri'
18
+ require 'text'
19
+
20
+ require 'crunchyroll/utils'
21
+ require 'crunchyroll/crunchyroll'
22
+ require 'crunchyroll/version'
@@ -0,0 +1,34 @@
1
+ module Crunchyroll
2
+ def self.find(series)
3
+ begin
4
+ url = ''
5
+ title = ''
6
+ cr = 'http://www.uswebproxy.com/index.php?q=aHR0cDovL3d3dy5jcnVuY2h5cm9sbC5jb20vbGluZXVw&hl=3ed'
7
+ Nokogiri::HTML(open(cr)).xpath('//div[@class="anime-grid-item"]').each { |r|
8
+ tmp = r.xpath('.//a/div/text()').to_s
9
+ if tmp.downcase.include? series.downcase
10
+ title = tmp
11
+ url = r.xpath('.//a/@href') .to_s
12
+ break
13
+ end
14
+ }
15
+ return false if title.empty? || url.empty?
16
+
17
+ air = Nokogiri::HTML(open(url)).xpath('//ul[@id="sidebar_elements"]/li')[1].xpath('.//p')[0].text
18
+
19
+ day_literal = air.split('Simulcast on ')[1].split(' ')[0]
20
+ date = DateTime.parse(air.split('Simulcast on ')[1]).date_of_next
21
+
22
+ return {
23
+ :title => title,
24
+ :where => 'Crunchyroll',
25
+ :day => day_literal,
26
+ :hour => date.hour.fix,
27
+ :min => date.min.fix,
28
+ :left => date.time_left(DateTime.now)
29
+ }
30
+ rescue
31
+ return false
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ class DateTime
2
+ def time_left(date)
3
+ a = self.to_time - 1*60*60
4
+ secs = (a - date.to_time).to_int
5
+ mins = secs / 60
6
+ hours = mins / 60
7
+ days = hours / 24
8
+
9
+ "#{days} days, #{hours % 24} hours, #{mins % 60} minutes and #{secs % 60} seconds"
10
+ end
11
+
12
+ def date_of_next
13
+ delta = self > DateTime.now ? 0 : 7
14
+ self + delta
15
+ end
16
+ end
17
+
18
+ class Fixnum
19
+ def fix
20
+ self > 9 ? self.to_s : "0#{self}"
21
+ end
22
+ end
@@ -0,0 +1,19 @@
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
+ ##
14
+
15
+ module Crunchyroll
16
+ def self.version
17
+ '0.1'
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crunchyroll
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Giovanni Capuano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: text
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Find and get infos about series airing on Crunchyroll.
42
+ email: webmaster@giovannicapuano.net
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/crunchyroll/crunchyroll.rb
48
+ - lib/crunchyroll/utils.rb
49
+ - lib/crunchyroll/version.rb
50
+ - lib/crunchyroll.rb
51
+ homepage: http://www.giovannicapuano.net
52
+ licenses:
53
+ - WTFPL
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.0.3
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Find a series airing on Crunchyroll.
75
+ test_files: []