my_manga 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b196ef7ec4b300ded6dc4a9270fa49d49ff3cfd43dea8f8d233e89132cdd03ad
4
- data.tar.gz: 9c6f245d09d9b6c0363f27b6f57c295e16f4f7c17bfb799c1eedb7e596528d5b
3
+ metadata.gz: 8048dd9700d83defc4357103548b3b358e62527c2d5d3bb9de5b1d89f716b5a2
4
+ data.tar.gz: 178175900d972d534d7d65313a6cfbc4c7f554879105fa3e87b153de23f2553b
5
5
  SHA512:
6
- metadata.gz: 600db7c50191c5605d4a92a55fb54886a9fe43cbaae4c94e618d85fc4ba4381c5476cc72cd83f7644be0189064f5797c69b6cb75e442751016306ec98f853b74
7
- data.tar.gz: 848b9553b785229c3043ae64293710d9dee26af9b629c00c25b6585b8eeb1c2891158137d235fba5db13d7a1b0877711ee1affd13051b037c189e83349e29693
6
+ metadata.gz: 2e3c823ad46dd4b7134aa19cd8d0141408c055624a7aa69ec00fe19ab7ad8a2b50fcdc54a34d2a4d964b10005c9d91541ca217ccb6bd2f4a783d82c9f86bf25c
7
+ data.tar.gz: e9505f800e91eca8f1fd55d1e5a706d9280870406d5e00879cc21acca85c046f9a37ebcd1b043da95d5455726bb4754f878df09c5e1ade8bbba6b833d5b5e7cd
data/README.md CHANGED
@@ -1,145 +1,2 @@
1
1
  TODO: Don't test cli with binary. Test the lib.
2
- TODO: Check out http://piotrmurach.github.io/tty/gems/ to make this gem better
3
-
4
- ```
5
- my_manga find "assassination classroom"
6
-
7
- Manga found for "assassination classroom"
8
- =========================================
9
- Name Url
10
- Assasination Classroom http://www.mangareader.net/assassination-classroom
11
-
12
- => nil
13
-
14
- my_manga add http://www.mangareader.net/assassination-classroom
15
-
16
- "Assassination Classroom" added to your library!
17
-
18
- => nil
19
-
20
- my_manga remove "Assassination Classroom"
21
-
22
- "Assassination Classroom" removed from your library!
23
-
24
- => nil
25
-
26
- my_manga list
27
-
28
- Manga list
29
- =======================================
30
- Name Chapters (read/total)
31
- Assassination Classroom 0/161
32
- Naruto 669/700
33
- Naruto Movie 10/10
34
-
35
- => nil
36
-
37
- my_manga download
38
-
39
- Downloading 161 Chapters from "Assassination Classroom"
40
- Downloading 1 Chapters from "Naruto"
41
- ...
42
- Finished Download!
43
-
44
- => nil
45
-
46
- my_manga download "Assassination Classroom"
47
-
48
- Downloading 0 Chapters from "Assassination Classroom"
49
- Finished Download!
50
-
51
- => nil
52
-
53
- my_manga download "Assassination Classroom" --from=1 --to=10
54
-
55
- Downloading 10 Chapters from "Assassination Classroom"
56
- Finished Download!
57
-
58
- => nil
59
-
60
- my_manga download "Assassination Classroom" --list=[11,13,15]
61
-
62
- Downloading 3 Chapters from "Assassination Classroom"
63
- Finished Download!
64
-
65
- => nil
66
-
67
- my_manga update
68
-
69
- Fetching Manga
70
- ...
71
- Updated "Assassination Classroom": 5 new Chapters.
72
-
73
- => nil
74
-
75
- my_manga update "Assassination Classroom"
76
-
77
- Fetching Manga
78
- ...
79
- Nothing to Update
80
-
81
- => nil
82
-
83
- my_manga list "Assasination Classroom"
84
-
85
- Manga details for "Assasination Classroom"
86
- =========================================
87
- Name Chapters (read/total)
88
- Assassination Classroom 161/166
89
-
90
- Chapters Read
91
- -------------
92
- Assasination Classroom 1
93
- Assasination Classroom 2
94
- Assasination Classroom 3
95
- ...
96
- Assasination Classroom 161
97
-
98
- => nil
99
-
100
- my_manga list -a "Naruto Movie"
101
-
102
- Manga details for "Naruto Movie"
103
- =========================================
104
- Name Chapters (read/total)
105
- Naruto Movie 161/166
106
-
107
- Chapters Read
108
- -------------
109
- Naruto Movie 1
110
- Naruto Movie 2
111
- Naruto Movie 3
112
- Naruto Movie 4
113
- Naruto Movie 5
114
- Naruto Movie 6
115
- Naruto Movie 7
116
- Naruto Movie 8
117
- Naruto Movie 9
118
- Naruto Movie 10
119
-
120
- => nil
121
-
122
- my_manga mark read "Assassination Classroom" --from=162 --to=165
123
-
124
- Chapters 162-165 from "Assination Classroom" Marked as Read
125
-
126
- => nil
127
-
128
- my_manga mark unread "Naruto Movie" --list=[2,3,4,7,8]
129
-
130
- Chapters 2, 3, 4, 7, 8 from "Naruto Movie" Marked as Unread
131
-
132
- => nil
133
-
134
- my_manga list
135
-
136
- Manga list
137
- =======================================
138
- Name Chapters (read/total)
139
- Assasination Classroom 165/166
140
- Naruto 700/700
141
- Naruto Movie 5/10
142
-
143
- => nil
144
-
145
- ````
2
+ TODO: Add retries and try to heal downloads. Also add an option for zine publish to finish a failed publication
@@ -39,6 +39,8 @@ module MyManga
39
39
 
40
40
  puts '...'
41
41
  puts 'Finished Download!'
42
+ rescue Mangdown::Error => e
43
+ puts "Failed to download: #{e.message}"
42
44
  end
43
45
  end
44
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyManga
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
@@ -7,7 +7,7 @@ module MyManga
7
7
  module Commands
8
8
  # See desc
9
9
  class Zine < MyManga::CLI::Command
10
- desc 'Build a new zine'
10
+ desc 'Build a new zine, or manage zine manga'
11
11
  argument :names, desc: 'Manga names (comma separated)'
12
12
 
13
13
  option :add,
@@ -18,6 +18,10 @@ module MyManga
18
18
  type: :boolean,
19
19
  default: false,
20
20
  desc: 'Remove manga from zine'
21
+ option :recover,
22
+ type: :boolean,
23
+ default: true,
24
+ desc: 'Recover failed zine'
21
25
  option :size,
22
26
  default: '10',
23
27
  desc: 'Number of chapters to include in the zine'
@@ -25,6 +29,7 @@ module MyManga
25
29
  desc: 'Filename for the zine, (default `zine-<timestamp>-<hash of chapters included>`)'
26
30
 
27
31
  TMP_DIR = File.expand_path('../../tmp', __dir__)
32
+ RECOVERY_FILE = File.expand_path('../../zine-recovery.yaml', __dir__)
28
33
 
29
34
  def call(names: nil, **options)
30
35
  names = manga_names(names)
@@ -36,6 +41,10 @@ module MyManga
36
41
  exit 1
37
42
  end
38
43
 
44
+ if options[:recover] == false && File.exist?(RECOVERY_FILE)
45
+ File.delete(RECOVERY_FILE)
46
+ end
47
+
39
48
  if options[:add]
40
49
  MyManga.add_to_zine(names)
41
50
  puts %("#{names.join(', ')}" added to the zine!)
@@ -50,30 +59,48 @@ module MyManga
50
59
  private
51
60
 
52
61
  def publish(filename, size)
53
- FileUtils.rm_r(TMP_DIR) if Dir.exist?(TMP_DIR)
54
- Dir.mkdir(TMP_DIR)
62
+ Dir.mkdir(TMP_DIR) unless Dir.exist?(TMP_DIR)
55
63
 
56
64
  zine = zine_content(size)
57
- serialized_name = []
58
- zine.each do |chapter|
59
- serialized_name << chapter.id
60
- chapter.to_md.download_to(TMP_DIR)
61
- MyManga.read!(chapter.manga, [chapter.number])
62
- end
63
65
 
64
- serialized_name = serialized_name.join.to_i.to_s(32)
65
- filename ||= "zine-#{Time.now.to_i}-#{serialized_name}"
66
+ File.write(RECOVERY_FILE, YAML.dump(zine.map(&:id)))
67
+
68
+ Chapter.transaction do
69
+ serialized_name = []
70
+ zine.each do |chapter|
71
+ serialized_name << chapter.id
72
+ MyManga.download_chapter(chapter, TMP_DIR)
73
+ MyManga.read!(chapter.manga, [chapter.number])
74
+ end
75
+
76
+ serialized_name = serialized_name.join.to_i.to_s(32)
77
+ filename ||= "zine-#{Time.now.to_i}-#{serialized_name}"
66
78
 
67
- dir = File.join(MyManga.download_dir, filename)
79
+ dir = File.join(MyManga.download_dir, filename)
68
80
 
69
- cbz(dir)
81
+ cbz(dir)
82
+ end
70
83
 
71
84
  FileUtils.rm_r(TMP_DIR)
85
+ File.delete(RECOVERY_FILE)
72
86
 
73
87
  puts "Pushlished a new zine (#{filename}) in #{MyManga.download_dir}"
88
+ rescue Mangdown::Error => e
89
+ puts "Failed to publish zine: #{e.message}"
90
+ end
91
+
92
+ def zine_content(size)
93
+ return new_zine_content(size) unless File.exist?(RECOVERY_FILE)
94
+
95
+ puts 'Recovering failed publication ...'
96
+
97
+ chapter_ids = YAML.load_file(RECOVERY_FILE)
98
+ Chapter.where(id: chapter_ids).sort_by do |chapter|
99
+ chapter_ids.index(chapter.id)
100
+ end
74
101
  end
75
102
 
76
- def zine_content(chapter_count)
103
+ def new_zine_content(chapter_count)
77
104
  manga = MyManga.zine
78
105
  chapters = Chapter
79
106
  .unread
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_manga
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-28 00:00:00.000000000 Z
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.19.0
47
+ version: 0.20.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.19.0
54
+ version: 0.20.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pg
57
57
  requirement: !ruby/object:Gem::Requirement