File size: 1,276 Bytes
2b16bc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7406982
2b16bc4
 
 
7406982
2b16bc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import argparse
import logging
import os

import sources
from detector import Detector
from downloader_manager import download_mp4_and_extract_audio
from sorter import SlideSorter


def process_video(link):
    try:
        temp_video_file_path, audio_path = download_mp4_and_extract_audio(link)

        detector = Detector(temp_video_file_path)
        logging.info("Detecting Slides...")
        detected_slides = detector.detect_slides()

        sorter = SlideSorter(sources.ListSource(detected_slides))
        logging.info("Sorting Slides...")
        sorted_slides = sorter.sort()

        os.remove(temp_video_file_path)
        return sorted_slides, audio_path

    except Exception as e:
        logging.exception("Failed to execute process_video: %s", e)
        return None, None


if __name__ == '__main__':
    Parser = argparse.ArgumentParser(description="File Processor")
    Parser.add_argument("-p", "--link")
    Args = Parser.parse_args()

    try:
        slides, path = process_video(Args.link)

        if slides is not None and path is not None:
            print("Video processed successfully.")
        else:
            print("Failed to process the video.")

    except Exception as e:
        logging.exception("An error occurred in main: %s", e)