Skip to content

Commit

Permalink
V : 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu committed Jun 12, 2017
1 parent 34ae53e commit fbc4278
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 42 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Changelog :

0.12.1 : stability increase + added the instruction "managed" to display the compatible websites<br />
0.12.0 : huge optimisation : download is close to twice as fast + new management of the parameters + more understandable errors<br />

###### Warning : the params database is not compatible<br />Please look at the file migration/0.11.x_to_0.12.x.txt<br />
Expand Down
1 change: 1 addition & 0 deletions install/archlinux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo pacman -S tk
gem install sqlite3
gem install colorize
gem install nokogiri
gem install typhoeus
gem install tk

add the following line to your .bashrc ( or .zshrc ) :
Expand Down
1 change: 1 addition & 0 deletions install/debian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ sudo apt-get install ruby-dev ruby2.3 ruby2.3-dev libsqlite3-dev build-essential
sudo gem install sqlite3
sudo gem install nokogiri
sudo gem install colorize
sudo gem install typhoeus
22 changes: 22 additions & 0 deletions sources/Download/base_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def link_err(data, chapter, disp)
if chapter
@db.add_todo(@manga_data, data[0], data[1], -1)
@aff.error_on_page_download(disp)
@aff.dump_chapter
else
@db.add_todo(@manga_data, data[0], data[1], data[2])
@aff.error_on_page_download(disp)
Expand All @@ -33,6 +34,27 @@ def validate_data(description, author, artist, type, status, genres, release, ht
end
end

def get_page_from_link(link, data, xpath)
begin
page = Utils_connection::get_page(link, true)
rescue RuntimeError
return link_err(data, false, 'r')
end
if page == nil
return false
end
pic_link = page.xpath(xpath).map{|img| img['src']}
if pic_link[0] == nil
return link_err(data, false, 'x')
end
pic_buffer = Utils_connection::get_pic(pic_link[0], true)
if pic_buffer == nil || Utils_file::write_pic(pic_buffer, data, @dir) == false
return link_err(data, false, '!')
end
@downloaded_a_page = true
true
end

public
# takes the data array [volume, chapter, page] and casts it into a string
def values_to_string(volume, chapter, page)
Expand Down
19 changes: 3 additions & 16 deletions sources/Download/mangafox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,7 @@ def link_generator(volume, chapter, page)

# downloads a page, with link = the link, data = [volume, chapter, page]
def page_link(link, data)
page = Utils_connection::get_page(link, true)
if page == nil
return false
end
pic_link = page.xpath('//img[@id="image"]').map{|img| img['src']}
if pic_link[0] == nil
return link_err(data, false, 'x')
end
pic_buffer = Utils_connection::get_pic(pic_link[0], true)
if pic_buffer == nil || Utils_file::write_pic(pic_buffer, data, @dir) == false
return link_err(data, false, '!')
end
@downloaded_a_page = true
true
get_page_from_link(link, data, '//img[@id="image"]')
end

# downloads a chapter with link = the link and prep_display = small string displayed when announcing the download of the chapter
Expand All @@ -80,13 +67,13 @@ def chapter_link(link, prep_display = '')
@aff.prepare_chapter("downloading #{data_to_string(data)} of #{@manga_data.name}" + prep_display)
number_of_pages = page.xpath('//div[@class="l"]').text.split.last.to_i
if number_of_pages == 0
raise 'could not get number of pages from page. Link = ' + link
return link_err(data, true, '?')
end
page_nb = 1
while page_nb <= number_of_pages
data[2] = page_nb
unless page_link(link, data)
return false
@aff.dump_chapter
end
@aff.downloaded_page(page_nb)
last_pos = link.rindex(/\//)
Expand Down
30 changes: 6 additions & 24 deletions sources/Download/mangareader_mangapanda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,29 @@ def link_generator(_volume, chapter, page)
end

def page_link(link, data)
begin
page = Utils_connection::get_page(link, true)
rescue RuntimeError
return link_err(data, false, 'r')
end
if page == nil
return false
end
pic_link = page.xpath('//img').map{|img| img['src']}
if pic_link[0] == nil
return link_err(data, false, 'x')
end
pic_buffer = Utils_connection::get_pic(pic_link[0], true)
if pic_buffer == nil || Utils_file::write_pic(pic_buffer, data, @dir) == false
return link_err(data, false, '!')
end
@downloaded_a_page = true
true
get_page_from_link(link, data, '//img')
end

def chapter_link(link, prep_display = '')
data = @manga_data.extract_values_from_link(link)
begin
page = Utils_connection::get_page(link, true)
if (page = Utils_connection::get_page(link, true)) == nil
return link_err(data, true, 'X')
end
rescue RuntimeError
return link_err(data, true, 'R')
end
if page == nil
return link_err(data, true, 'X')
end
@aff.prepare_chapter("downloading chapter #{data[1]} of #{@manga_data.name}" + prep_display)
number_of_pages = page.xpath('//option').last.text.to_i
if number_of_pages == 0
raise 'could not get number of pages from page. Link = ' + link
return link_err(data, true, '?')
end
page_nb = 1
link += '/1'
while page_nb <= number_of_pages
data[2] = page_nb
unless page_link(link, data)
return false
@aff.dump_chapter
end
@aff.downloaded_page(page_nb)
last_pos = link.rindex(/\//)
Expand Down
2 changes: 1 addition & 1 deletion sources/api/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.help
file = File.open('sources/templates/text/help.txt', 'r')
content = file.read
content = content.gsub('_todo', 'todo')
instructions = %w(link id file query all add update fast-update download redl re-download p c v param version help list output delete delete-db details html todo clear todo reset set data)
instructions = %w(link id file query all add update fast-update download redl re-download p c v param version help list output delete delete-db details html todo clear todo reset set data managed)
instructions.each do |instruction|
content = content.gsub('[' + instruction + ']g', instruction.green).gsub('[' + instruction + ']y', instruction.yellow)
end
Expand Down
6 changes: 6 additions & 0 deletions sources/instructions/Instructions_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def init_parser_utilities
buff = get_valid_data('list', false, args, false)
MangaScrap_API::details(buff) unless buff.empty?
end
@parser.on 'managed' do ||
puts "managed websites are :\n\n"
Manga_data::get_compatible_sites.sort.each do |link|
puts link
end
end
end

def init_parser_mangas_related
Expand Down
4 changes: 4 additions & 0 deletions sources/templates/text/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
[version]g
displays the current version of MangaScrap witch can be found in utils/version.txt

[managed]g
displays the list of the compatible websites that MangaScrap is able to scrap

[data arguments]
definition : the data arguments are the arguments that are used to get elements by [link]y, [id]y, [file]y, ...

Expand Down Expand Up @@ -166,3 +169,4 @@
x => could not download the html page ( needed to get to the image )
! => could not download the image
r => got redirected when trying to connect to the link
? => could not extract the pages from the html
2 changes: 1 addition & 1 deletion sources/templates/text/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.5
0.12.1

0 comments on commit fbc4278

Please sign in to comment.