@@ -29,19 +29,19 @@ class Episode extends FilesDownloader {
2929 }
3030
3131 initOptions ( {
32- splitSize,
33- illustrationRenameFormat ,
34- illustrationImageRenameFormat ,
32+ splitSize = 1000 ,
33+ renameFormat ,
34+ imageRenameFormat ,
3535 pageNumberStartWithOne = false ,
36- illustrationPageNumberLength ,
36+ pageNumberLength ,
3737 processors = 2 ,
3838 pack = true
3939 } ) {
4040 this . splitSize = splitSize ;
41- this . illustrationRenameFormat = illustrationRenameFormat
42- this . illustrationImageRenameFormat = illustrationImageRenameFormat ;
41+ this . renameFormat = renameFormat
42+ this . imageRenameFormat = imageRenameFormat ;
4343 this . pageNumberStartWithOne = pageNumberStartWithOne ;
44- this . illustrationPageNumberLength = illustrationPageNumberLength ;
44+ this . pageNumberLength = pageNumberLength ;
4545 this . processors = processors ;
4646 this . pack = pack ;
4747 this . relativePath = '' ;
@@ -53,7 +53,7 @@ class Episode extends FilesDownloader {
5353 }
5454
5555 init ( ) {
56- this . relativePath = formatName ( this . illustrationRenameFormat , this . context , this . context . illustId ) ;
56+ this . relativePath = formatName ( this . renameFormat , this . context , this . getId ( ) ) ;
5757 this . chunks = [ ] ;
5858 this . filename = null ;
5959 this . zips = null ;
@@ -78,10 +78,10 @@ class Episode extends FilesDownloader {
7878 startIndex = chunk . end + 1 ;
7979 }
8080
81- if ( ! self . illustrationImageRenameFormat ||
82- self . illustrationImageRenameFormat . indexOf ( '{pageNum}' ) < 0
81+ if ( ! self . imageRenameFormat ||
82+ self . imageRenameFormat . indexOf ( '{pageNum}' ) < 0
8383 ) {
84- self . illustrationImageRenameFormat += '{pageNum}' ;
84+ self . imageRenameFormat += '{pageNum}' ;
8585 }
8686 }
8787
@@ -94,32 +94,28 @@ class Episode extends FilesDownloader {
9494 this . context [ key ] = value ;
9595 }
9696
97- getUserId ( ) {
98- return this . context . userId
99- }
100-
101- getUserName ( ) {
102- return this . context . userName
97+ getId ( ) {
98+ return this . context . id
10399 }
104100
105- getId ( ) {
106- return this . context . illustId
101+ getUniqueId ( ) {
102+ return `pixiv-comic-episode: ${ this . getId ( ) } ` ;
107103 }
108104
109105 getImages ( ) {
110- return this . context . urls
106+ return this . context . pages
111107 }
112108
113109 getThumb ( ) {
114- return this . getImages ( ) . thumb ;
110+ return this . getImages ( ) [ 0 ] ;
115111 }
116112
117113 getTitle ( ) {
118- return this . context . illustTitle
114+ return this . context . title ;
119115 }
120116
121117 isR ( ) {
122- return ! ! this . context . r
118+ return false ;
123119 }
124120
125121 /**
@@ -128,7 +124,7 @@ class Episode extends FilesDownloader {
128124 * @returns {Boolean }
129125 */
130126 isSingle ( ) {
131- return this . pagesNumber ( ) === 1
127+ return false ;
132128 }
133129
134130 /**
@@ -168,11 +164,11 @@ class Episode extends FilesDownloader {
168164 let pageNum = index + ( this . pageNumberStartWithOne ? 1 : 0 ) ;
169165
170166 this . context . pageNum = this . getPageNumberString (
171- pageNum , this . context . pages . length , this . illustrationPageNumberLength
167+ pageNum , this . context . pages . length , this . pageNumberLength
172168 ) ;
173169
174170 return formatName (
175- this . illustrationImageRenameFormat . replace ( this . isSingle ( ) ? / # .* # / g : / # / g, '' ) ,
171+ this . imageRenameFormat . replace ( this . isSingle ( ) ? / # .* # / g : / # / g, '' ) ,
176172 this . context ,
177173 pageNum
178174 ) ;
@@ -183,7 +179,7 @@ class Episode extends FilesDownloader {
183179 * @returns {string }
184180 */
185181 getPackedFilename ( ) {
186- return formatName ( this . illustrationRenameFormat , this . context , this . context . illustId ) ;
182+ return formatName ( this . renameFormat , this . context , this . getId ( ) ) ;
187183 }
188184
189185 /**
@@ -214,7 +210,7 @@ class Episode extends FilesDownloader {
214210
215211 this . context . pageNum = pageNum ;
216212
217- let format = this . illustrationImageRenameFormat . replace ( / # .* # / g, '' ) ;
213+ let format = this . imageRenameFormat . replace ( / # .* # / g, '' ) ;
218214
219215 let filename = formatName ( format , this . context , pageNum ) + '.' + MimeType . getExtenstion ( download . getResponseHeader ( 'Content-Type' ) ) ;
220216
0 commit comments