Added support for conversion to any filetype supported by ffmpeg
This commit is contained in:
		
							parent
							
								
									d6424add61
								
							
						
					
					
						commit
						1c1b1398ea
					
				
					 1 changed files with 14 additions and 6 deletions
				
			
		
							
								
								
									
										20
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								main.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -16,13 +16,18 @@ def main():
 | 
			
		|||
 | 
			
		||||
    parser.add_argument("-n", "--name", action="store_true", help="rename videos")
 | 
			
		||||
 | 
			
		||||
    parser.add_argument("-c", "--classify", action="store_true", help="assign a category to videos to move them into corresponding folders")
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "-c",
 | 
			
		||||
        "--classify",
 | 
			
		||||
        action="store_true",
 | 
			
		||||
        help="assign a category to videos to move them into corresponding folders",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "-r",
 | 
			
		||||
        "--reformat",
 | 
			
		||||
        action="store_true",
 | 
			
		||||
        help="automatically convert videos to mp4 using ffmpeg",
 | 
			
		||||
        default="mp4",
 | 
			
		||||
        help="automatically convert videos using ffmpeg. defaults to mp4, supports any formats supported by ffmpeg",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    parser.add_argument("-v", "--verbose", action="store_true")
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +80,9 @@ def main():
 | 
			
		|||
            newname = file
 | 
			
		||||
        if args.classify:
 | 
			
		||||
            print(f"Existing categories: {os.listdir(outputFolder)}")
 | 
			
		||||
            category: str = input("Enter category or delete to permanently delete file: ")
 | 
			
		||||
            category: str = input(
 | 
			
		||||
                "Enter category or delete to permanently delete file: "
 | 
			
		||||
            )
 | 
			
		||||
            if category == "delete":
 | 
			
		||||
                os.remove(inputFolder + file)
 | 
			
		||||
            elif not os.path.exists(outputFolder + category) or not os.path.isdir(
 | 
			
		||||
| 
						 | 
				
			
			@ -90,13 +97,14 @@ def main():
 | 
			
		|||
            path = outputFolder + category + "/" + newname + extension
 | 
			
		||||
        shutil.move(inputFolder + file, path)
 | 
			
		||||
        if args.reformat:
 | 
			
		||||
            if extension != ".mp4":
 | 
			
		||||
            outformat = args.reformat
 | 
			
		||||
            if extension != f".{outformat}":
 | 
			
		||||
                subprocess.run(
 | 
			
		||||
                    ["ffmpeg"],
 | 
			
		||||
                    ["-i"],
 | 
			
		||||
                    [path],
 | 
			
		||||
                    ["-o"],
 | 
			
		||||
                    ["mp4"],
 | 
			
		||||
                    [outformat],
 | 
			
		||||
                    [f"{outputFolder}{category}{newname}.mp4"],
 | 
			
		||||
                )
 | 
			
		||||
                if args.verbose:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue