1
1
import logging
2
2
import os
3
- import bin .m2emHelper as helper
4
- from bin .m2emConverter import Converter
5
-
3
+ import bin .Helper as helper
4
+ from bin .Converter import Converter
6
5
7
6
def ConverterHandler (config , args ):
8
-
9
- # Load configs required here
10
- database = config ["Database" ]
7
+ """ Function that handles the Converter in a loop """
11
8
12
9
# Load Chapters!
13
- chapters = helper .getChapters (database )
10
+ chapters = helper .getChapters ()
14
11
15
12
16
13
# Start conversion loop!
17
- for chapter in chapters :
18
-
14
+ for chapter in chapters .iterator ():
19
15
20
16
21
17
# Verify if chapter has been downloaded already
22
18
if not helper .verifyDownload (config , chapter ):
23
- logging .debug ("Manga %s has not been downloaded!" % chapter [ 2 ] )
19
+ logging .debug ("Manga %s has not been downloaded!" , chapter . title )
24
20
else :
25
21
26
22
27
23
# Spawn an Converter Object & get basic data from database & config
28
24
current_conversation = Converter ()
29
- current_conversation .data_collector (config ,chapter )
25
+ current_conversation .data_collector (config , chapter )
30
26
31
27
# Check if Download loop & Download task is selected
32
28
if not args .start :
@@ -39,21 +35,19 @@ def ConverterHandler(config, args):
39
35
current_conversation .cbz_creator ()
40
36
current_conversation .eb_creator ()
41
37
else :
42
- logging .debug ("%s is older than 24h, will not be processed by daemon." % current_conversation .mangatitle )
38
+ logging .debug ("%s is older than 24h, will not be processed by daemon." ,
39
+ current_conversation .mangatitle )
43
40
44
41
45
42
46
43
47
44
def directConverter (config , chapterids = []):
45
+ """ Function that handles direct calls of the Converter """
48
46
49
47
logging .debug ("Following Chapters are directly converted:" )
50
48
logging .debug (chapterids )
51
49
52
- # Load configs required here
53
- database = config ["Database" ]
54
-
55
-
56
- chapters = helper .getChaptersFromID (database , chapterids )
50
+ chapters = helper .getChaptersFromID (chapterids )
57
51
58
52
59
53
if not chapters :
@@ -64,23 +58,23 @@ def directConverter(config, chapterids=[]):
64
58
65
59
# Verify if chapter has been downloaded already
66
60
if not helper .verifyDownload (config , chapter ):
67
- logging .info ("Manga %s has not been downloaded!" % chapter [2 ])
61
+ logging .info ("Manga %s has not been downloaded!" , chapter [2 ])
68
62
else :
69
63
70
64
71
65
# Spawn an Converter Object & get basic data from database & config
72
66
current_conversation = Converter ()
73
- current_conversation .data_collector (config ,chapter )
67
+ current_conversation .data_collector (config , chapter )
74
68
75
69
if os .path .exists (current_conversation .cbzlocation ):
76
- logging .info ("Manga %s converted to CBZ already!" % current_conversation .mangatitle )
70
+ logging .info ("Manga %s converted to CBZ already!" ,
71
+ current_conversation .mangatitle )
77
72
else :
78
- logging .info ("Starting conversion to CBZ of %s..." % current_conversation .mangatitle )
79
73
current_conversation .cbz_creator ()
80
74
81
75
# Start conversion to Ebook format!
82
76
if os .path .exists (current_conversation .eblocation ):
83
- logging .info ("Manga %s converted to Ebook already!" % current_conversation .mangatitle )
77
+ logging .info ("Manga %s converted to Ebook already!" ,
78
+ current_conversation .mangatitle )
84
79
else :
85
- logging .info ("Starting conversion to Ebook of %s..." % current_conversation .mangatitle )
86
80
current_conversation .eb_creator ()
0 commit comments