Code Monkey home page Code Monkey logo

vidsiv's Introduction

                 ;                                                   
                 ED.                                                 
                 E#Wi                               .                
             t   E###G.                            ;W t              
             Ej  E#fD#W;                          f#E Ej             
 t      .DD. E#, E#t t##L                       .E#f  E#, t      .DD.
 EK:   ,WK.  E#t E#t  .E#K,                    iWW;   E#t EK:   ,WK. 
 E#t  i#D    E#t E#t    j##f                  L##Lffi E#t E#t  i#D   
 E#t j#f     E#t E#t    :E#K:                tLLG##L  E#t E#t j#f    
 E#tL#i      E#t E#t   t##L                    ,W#i   E#t E#tL#i     
 E#WW,       E#t E#t .D#W;                    j#E.    E#t E#WW,      
 E#K:        E#t E#tiW#G.                   .D#j      E#t E#K:       
 ED.         E#t E#K##i       ,;;;;;;;;;.  ,WK,       E#t ED.        
 t           E#t E##D.        jLLLLLLLLLL, EG.        E#t t          
             ,;. E#t                       ,          ,;.            
                 L:                                              

Vid Siv

Hewo!

Vid_Siv is a video sieve for low quality (>480) videos.

This rather simple script does the following:

  • It recursively traverses a directory looking for video files.
  • When it finds one, it makes sure it is an actual video file.
  • It then checks to see if the file has a size less than configured amount.
  • If the file does not meet the minimum required file size it removes it.
  • If it does, it then checks to see if the file meets the minimum duration requirement.
  • Like before, if the file fails, it is removed. If it succeeds, it moves on to the next filter.
  • Lastly, it probes the file for the width. The width is often used to designate quality.
  • If the video width does not meet the designated minimum amount, it deletes the file.
  • The script is used for removing low quality video files from your system.

Because, the nineties were not the best time for high def video.

Install

Use python poetry to install with poetry install or use pipenv to install with pipenv install. Which ever is your choice. Which would look like so:

poetry install

or

pipenv install

Options

I did tried to provide the user with as many options to customize as possible.

In table form:

Option flag What it does
directory --dir Directory to search in
quality --qty Desired quality (width)
duration --dur Enable and set minimum duration
remove --rm Enable file removal
no zero --nozo Disable zero sum deletion
minimum --min file size for zero sum
log level --lev Set log level to DEBUG or INFO
log file --log Log file path
rotate log --rot Rotate log file when > 512

In raw class form:

    """Vidsiv helps you remove zero-sum, low quality, and short videos from folders recursively."""
    dir: str = os.path.expanduser('~/Videos')  # Path of the directory you want sieved.
    qty: str = choice("480", "540", "720", "1080", "2k", "4k", default='720')  # Choose minimum desired quality in width
    dur: int = 60  # Enable and set Minimum allowed duration in secs.
    rm: bool = True  # Enable/Disable deletion of low quality files.
    zo: bool = True  # Enable/Disable removal of zero-sum files.
    min: int = 512  # Minimum file size in kilobytes, less than is considered zero-sum.
    lev: str = choice('info', 'debug', default='info')  # Set log level to either INFO or DEBUG
    log: str = os.path.abspath('./vidsiv.log')  # Full path to log file.
    rot: bool = True  # Enable/Disable auto rotate log file when > 1MB

Usage

Using Vid_Siv would look something like so:

poetry run python vidsiv.py --dir /dir/path --rm
  • All options possess a default value.
  • If no directory is specified on the command line, the script will default to using /home/$USER/Videos.
  • If the --rm flag is not used, the script will do nothing. This is so to prevent accidental deletion of files.
  • As a "bonus" feature, you can use the --dur flag and remove files based on minimum size as well.
  • If you have files less than 512kb that you want to keep, you can either disable zero-sum with --noz or change it with --min 256.

Caveats

During generation of the file list two approaches were tested, one using normal python file functions, and the other using trio's asynchronous file functions. For small sets of files, trio's file handling functions outpaced normal file handling functions by a large margin, but with large sets of files the difference in processing time became much closer. Still trio's file handling functions was 0.2 secs faster than the standard file handling functions, averaging about 1.2 secs per file for over 4,000 files. We wish it was faster.

Thanks

A massively warm thanks goes to the trio gitter channel, who taught me a lot and helped me to troubleshoot this project.

A special thanks goes out to Arthur Tacca for realizing and providing the missing feature to the trio asynchronous library, i.e. aioresult.

License

https://anoduck.mit-license.org

vidsiv's People

Contributors

anoduck avatar

Watchers

 avatar  avatar

vidsiv's Issues

TypeError: object of type 'NoneType' has no len()

Occurring in line 266 of file vidsiv.py after the function get_flist() has completed. Traced to the return value of each trio task return value in the previously mentioned function. ret2 = ResultCapture.start_soon(nsy, find_videos, recvlist.clone(), bar, log). Return values of trio tasks are being returned with nonetype.

ret1 = ResultCapture.start_soon(nsy, find_videos,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.