yotsuba 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59a88ded5fdaa24188b03622698bfff64ad1b8c9
4
+ data.tar.gz: 997d1b6d50c45cbac447af7332736b54d98ec211
5
+ SHA512:
6
+ metadata.gz: 3dfd1fe9bd5210174aea85361ab36d68201220c7613588f21f521f2b68415dacb000a3ed0c8ffbed8ac61a04700175a8b506be059a72190798899ddbdc5eb33d
7
+ data.tar.gz: b4b670c5dc89abeea4e77c30dc66b876765a51986bd1ebb594816168f02c1a3c4d0a5593e7f56cf8587c2546231f6897f3c1fcc01346549f2aa615ea54502c21
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yotsuba.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Suchipi Izumi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Yotsuba
2
+
3
+ Yotsuba facilitates getting download links from the DomDomSoft Anime Downloader server.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yotsuba'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install yotsuba
20
+
21
+ ## Usage
22
+
23
+ Quick Start
24
+
25
+ $ export DOMDOM_KEY='your-domdom-key-goes-here'
26
+
27
+ ```ruby
28
+ anime = Yotsuba::Anime["Clannad: After Story"]
29
+ anime.files # => Array of episode files
30
+ episode = anime.files.first # Get the first file from the anime
31
+ episode.download_links # => Array of download links (zip parts)
32
+ ```
33
+
34
+ Verbose Example
35
+ ```ruby
36
+ Yotsuba.get_animes # explicitly download the anime list. Yotsuba::Anime.all and Yotsuba::Anime[] call this automatically.
37
+ Yotsuba::Anime.clear_anime_list! # explicitly clear the anime list. It will be automatically cleared when you use get_animes so there's not often a reason to use this.
38
+ Yotsuba::Anime.all # All the Animes. Will remain cached until you redownload the list.
39
+
40
+ Yotsuba::Anime[123] # Returns the Anime object with id 123.
41
+ Yotsuba::Anime["Title"] # Returns the Anime object with title "Title".
42
+ Yotsuba::Anime[/Sword/] # Returns an array of all Animes whose titles match the supplied regexp.
43
+
44
+ anime = Yostuba::Anime["Some Anime"]
45
+ anime.files # Returns all the File objects from the anime.
46
+ anime.id # => 123
47
+ anime.title # => "Some Anime"
48
+ anime.num_files # 24
49
+ # Note that anime.files requests file info from the server, but anime.num_files does not, so it's faster than anime.files.length
50
+
51
+ :id, :name, :size, :first_downloaded, :times_downloaded, :anime_id
52
+ episode = anime.files.first
53
+ episode.id # => 1234
54
+ episode.name # => "[Coolsubs] Some Anime Episode 01 [12B4D2].mp4"
55
+ episode.size # file size in bytes
56
+ episode.first_downloaded # Date object of the first time you downloaded this file
57
+ episode.times_downloaded # How many times you have downloaded this file before
58
+ episode.anime_id # => 123
59
+ episode.anime # Anime object that owns this episode
60
+ episode.download_links # Returns array of download links (zip parts)
61
+ ```
62
+
63
+ ## Development
64
+
65
+ 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.
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/suchipi/yotsuba/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yotsuba"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/yotsuba.rb ADDED
@@ -0,0 +1,134 @@
1
+ require 'yotsuba/version'
2
+ require 'savon'
3
+
4
+ module Yotsuba
5
+
6
+ Serial = ENV['DOMDOM_KEY']
7
+
8
+ class Anime
9
+ attr_reader :id, :title, :num_files
10
+
11
+ @@all_animes = []
12
+
13
+ def initialize(options = {id: nil, title: nil, num_files: nil})
14
+ @id = options[:id]
15
+ @title = options[:title]
16
+ @num_files = options[:num_files]
17
+ @@all_animes << self if self.valid?
18
+ return self
19
+ end
20
+
21
+ def valid?
22
+ self.id != nil && self.title != nil && self.num_files != nil
23
+ end
24
+
25
+ def files
26
+ @files ||= Yotsuba.get_files(self)
27
+ end
28
+
29
+ def self.clear_anime_list!
30
+ @@all_animes = []
31
+ end
32
+
33
+ def self.all
34
+ Yotsuba.get_animes if @@all_animes.length == 0
35
+ @@all_animes
36
+ end
37
+
38
+ def self.[](key)
39
+ Yotsuba.get_animes if @@all_animes.length == 0
40
+ results = []
41
+ single = false
42
+
43
+ search = Proc.new { |a|
44
+ single = true
45
+ results << a if a.title == key
46
+ } if key.is_a?(String)
47
+
48
+ search = Proc.new { |a|
49
+ single = true
50
+ results << a if a.id == key
51
+ } if key.is_a?(Fixnum)
52
+
53
+ search = Proc.new { |a|
54
+ single = false
55
+ results << a if a.title.match(key)
56
+ } if key.is_a?(Regexp)
57
+
58
+ raise(ArgumentError, "Argument should be a String (title), Fixnum (id), or Regexp.") if search.nil?
59
+
60
+ @@all_animes.each &search
61
+ return single ? results[0] : results
62
+
63
+ end
64
+
65
+ end
66
+
67
+ class File
68
+
69
+ attr_reader :id, :name, :size, :first_downloaded, :times_downloaded, :anime_id
70
+
71
+ def initialize(options = {id: nil, name: nil, size: nil, first_downloaded: nil, times_downloaded: nil, anime_id: nil})
72
+ @id = options[:id]
73
+ @name = options[:name]
74
+ @size = options[:size]
75
+ @first_downloaded = options[:first_downloaded]
76
+ @times_downloaded = options[:times_downloaded]
77
+ @anime_id = options[:anime_id]
78
+ return self
79
+ end
80
+
81
+ def anime
82
+ @anime ||= Yotsuba::Anime[self.anime_id]
83
+ end
84
+
85
+ def download_links
86
+ @download_links ||= Yotsuba.get_download_links(self)
87
+ end
88
+
89
+ end
90
+
91
+ def self.setup_savon
92
+ @client ||= Savon.client(wsdl: 'http://anime.domdomsoft.com/Services/MainService.asmx?wsdl')
93
+ end
94
+
95
+ def self.get_animes
96
+ setup_savon
97
+ Anime.clear_anime_list!
98
+ response = @client.call(:get_anime_list)
99
+ animes = response.body[:get_anime_list_response][:get_anime_list_result][:anime]
100
+ animes.each do |a|
101
+ Anime.new({
102
+ id: a[:id].to_i,
103
+ title: a[:title],
104
+ num_files: a[:num_file].to_i
105
+ })
106
+ end
107
+ return animes.length > 0
108
+ end
109
+
110
+ def self.get_files(anime)
111
+ setup_savon
112
+ response = @client.call(:get_list_episode, message: { animeTitle: anime.title, serial: Serial })
113
+ files = response.body[:get_list_episode_response][:get_list_episode_result][:episode_file]
114
+ results = []
115
+ files.each do |f|
116
+ results << File.new({
117
+ id: f[:id].to_i,
118
+ name: f[:name],
119
+ size: f[:file_size].to_i,
120
+ first_downloaded: f[:first_download_time_in_day],
121
+ times_downloaded: f[:download_times].to_i,
122
+ anime_id: anime.id
123
+ })
124
+ end
125
+ return results
126
+ end
127
+
128
+ def self.get_download_links(file)
129
+ setup_savon
130
+ response = @client.call :request_link_download2, message: { animeTitle: file.anime.title, episodeName: file.name, serial: Serial }
131
+ links = response.body[:request_link_download2_response][:request_link_download2_result].split('|||')
132
+ end
133
+
134
+ end
@@ -0,0 +1,3 @@
1
+ module Yotsuba
2
+ VERSION = "0.1.0"
3
+ end
data/yotsuba.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yotsuba/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yotsuba"
8
+ spec.version = Yotsuba::VERSION
9
+ spec.authors = ["Suchipi Izumi"]
10
+ spec.email = ["me@suchipi.com"]
11
+
12
+ spec.summary = %q{Yotsuba facilitates getting download links from the DomDomSoft Anime Downloader server.}
13
+ spec.homepage = "https://github.com/suchipi/yotsuba"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_dependency "savon", ">= 2.11.0"
25
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yotsuba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Suchipi Izumi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: savon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.11.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.11.0
69
+ description:
70
+ email:
71
+ - me@suchipi.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/yotsuba.rb
86
+ - lib/yotsuba/version.rb
87
+ - yotsuba.gemspec
88
+ homepage: https://github.com/suchipi/yotsuba
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.5
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Yotsuba facilitates getting download links from the DomDomSoft Anime Downloader
112
+ server.
113
+ test_files: []