示例#1
0
def ConverterHandler(args):
    """ Function that handles the Converter in a loop """

    # Load Chapters!
    chapters = helper.getChapters()

    # Start conversion loop!
    for chapter in chapters.iterator():

        # Verify if chapter has been downloaded already
        if not helper.verifyDownload(chapter):
            logging.debug("Manga %s has not been downloaded!", chapter.title)
        else:

            # Spawn an Converter Object & get basic data from database & config
            current_conversation = Converter()
            current_conversation.data_collector(chapter)

            # Check if Download loop & Download task is selected
            if not args.start:
                current_conversation.cbz_creator()
                current_conversation.eb_creator()
            else:

                # Only start run if chapter is younger than 24h
                if helper.checkTime(current_conversation.chapterdate):
                    current_conversation.cbz_creator()
                    current_conversation.eb_creator()
                else:
                    logging.debug(
                        "%s is older than 24h, will not be processed by daemon.",
                        current_conversation.mangatitle)
示例#2
0
def SenderHandler(args):
    """ Function that handles the sending of ebooks when a loop is called """

    # Get all Chapters
    chapters = helper.getChapters()

    # Load Users
    users = helper.getUsers()

    # Debug Users:
    logging.debug("Userlist:")
    for i in users:
        logging.debug(i.name)

    # Start conversion loop!
    for chapter in chapters.iterator():

        # Initiate Sender class and fill it with data
        current_sender = Sender()
        current_sender.data_collector(chapter)
        current_sender.users = users

        # Check if ebook has been converted yet, else skip
        if not os.path.exists(current_sender.eblocation):
            logging.debug("Manga %s has not been converted yet.",
                          current_sender.mangatitle)
        else:

            # Check if Chapter has been sent already
            if current_sender.issent != 0:
                logging.debug("%s has been sent already!",
                              current_sender.mangatitle)
            else:

                # Check if Sender loop or Sender task is selected
                if not args.start:
                    logging.info("Sending %s...", current_sender.mangatitle)
                    current_sender.send_eb()
                else:

                    # Only start run if chapter is younger than 24h
                    if helper.checkTime(current_sender.chapterdate):
                        logging.info("Sending %s...",
                                     current_sender.mangatitle)
                        current_sender.send_eb()
                    else:
                        logging.debug(
                            "%s is older than 24h, will not be processed by daemon.",
                            current_sender.mangatitle)
示例#3
0
def downloader(args):
    """ the downloader function """

    # Make the query
    chapters = helper.getChapters()

    if args.start:
        logging.debug("The loop will only consider Chapters younger than 24h!")



    # Start Download loop!
    for chapter in chapters.iterator():

        # Initialize Downloader class & load basic params
        current_chapter = Downloader()
        current_chapter.data_collector(chapter)


        # Check if the old DL location is being used and fix it!
        oldlocation = str(current_chapter.saveloc + current_chapter.mangatitle)
        newlocation = str(current_chapter.saveloc + current_chapter.manganame)
        if os.path.isdir(oldlocation):
            logging.info("Moving %s from old DL location to new one...", current_chapter.mangatitle)
            helper.createFolder(newlocation)
            move(oldlocation, newlocation)



        # Check if chapter needs to be downloaded
        if helper.verifyDownload(chapter):
            logging.debug("Manga %s downloaded already!", current_chapter.mangatitle)
        else:

            # Check if Download loop & Download task is selected
            if not args.start:
                current_chapter.data_processor()
            else:
                # Only start run if chapter is younger than 24h
                if  helper.checkTime(current_chapter.chapterdate):
                    current_chapter.data_processor()
                else:
                    logging.debug("%s is older than 24h, will not be processed by daemon.", current_chapter.mangatitle)