Module: Yotsuba::Messenger
- Defined in:
- lib/yotsuba/messenger.rb
Class Method Summary collapse
- .get_animes(options = {use_cache: false}) ⇒ Object
- .get_download_links(file) ⇒ Object
- .get_files(anime) ⇒ Object
Class Method Details
.get_animes(options = {use_cache: false}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/yotsuba/messenger.rb', line 4 def self.get_animes( = {use_cache: false}) setup return @animes if [:use_cache] && @animes.length > 0 response = @client.call(:get_anime_list) animes = response.body[:get_anime_list_response][:get_anime_list_result][:anime] animes = [animes] unless animes.is_a?(Array) results = [] animes.each do |a| results << { id: a[:id].to_i, title: a[:title], num_files: a[:num_file].to_i } end @animes = results if [:use_cache] return results end |
.get_download_links(file) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/yotsuba/messenger.rb', line 41 def self.get_download_links(file) setup response = @client.call :request_link_download2, message: { animeTitle: file.anime.title, episodeName: file.name, serial: Yotsuba::Serial } links = response.body[:request_link_download2_response][:request_link_download2_result].split('|||') links = [links] unless links.is_a?(Array) return links end |
.get_files(anime) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yotsuba/messenger.rb', line 22 def self.get_files(anime) setup response = @client.call(:get_list_episode, message: { animeTitle: anime.title, serial: Yotsuba::Serial }) files = response.body[:get_list_episode_response][:get_list_episode_result][:episode_file] files = [files] unless files.is_a?(Array) results = [] files.each do |f| results << { id: f[:id].to_i, name: f[:name], size: f[:file_size].to_i, first_downloaded: f[:first_download_time_in_day], times_downloaded: f[:download_times].to_i, anime: anime } end return results end |