Skip to content

Commit

Permalink
solved the linting error in already existing other scripts video_crop…
Browse files Browse the repository at this point in the history
…per and pdf_watermarkadder
  • Loading branch information
Davda-James committed Oct 2, 2024
1 parent 9e772ef commit 4f714df
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pdf_watermarkadder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def makepdf():
pdf_file = input("PDF file: ")
watermark = 'watermark.pdf'
merged = "finalDraft.pdf"
with open(pdf_file, "rb") as input_file,\
with open(pdf_file, "rb") as input_file, \
open(watermark, "rb") as watermark_file:
input_pdf = PdfFileReader(input_file)
watermark_pdf = PdfFileReader(watermark_file)
Expand Down
51 changes: 42 additions & 9 deletions video_cropper/video_cropper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def to_int(a, rel_to):
If string contains "%" it converts it to a float and multiplies by rel_to
EG: 50% -> 0.5*rel_to
'''
if type(a) == int:

if isinstance(a):
return a
else:
if '%' in a:
Expand All @@ -25,13 +26,41 @@ def to_int(a, rel_to):
parser = argparse.ArgumentParser()

parser.add_argument('-i', '--input', type=str, help='the file to crop')
parser.add_argument('-c', '--crop', type=str, help='the amount to crop in the format "TOP,BOTTOM,LEFT,RIGHT"')
parser.add_argument('-t', '--top', type=str, help='the amount to crop off the top of the video')
parser.add_argument('-b', '--bottom', type=str, help='the amount to crop off the bottom of the video')
parser.add_argument('-l', '--left', type=str, help='the amount to crop off the left of the video')
parser.add_argument('-r', '--right', type=str, help='the amount to crop off the right of the video')
parser.add_argument('-o', '--output', type=str, help='the file to output to (cannot be the same as input file)')
parser.add_argument('-y', '--yes', action='store_true', help='skip the prompt to confirm overwriting a file')
parser.add_argument(
'-c',
'--crop',
type=str,
help='the amount to crop in the format "TOP,BOTTOM,LEFT,RIGHT"')
parser.add_argument(
'-t',
'--top',
type=str,
help='the amount to crop off the top of the video')
parser.add_argument(
'-b',
'--bottom',
type=str,
help='the amount to crop off the bottom of the video')
parser.add_argument(
'-l',
'--left',
type=str,
help='the amount to crop off the left of the video')
parser.add_argument(
'-r',
'--right',
type=str,
help='the amount to crop off the right of the video')
parser.add_argument(
'-o',
'--output',
type=str,
help='the file to output to (cannot be the same as input file)')
parser.add_argument(
'-y',
'--yes',
action='store_true',
help='skip the prompt to confirm overwriting a file')

args = parser.parse_args()

Expand Down Expand Up @@ -107,7 +136,11 @@ def to_int(a, rel_to):
sys.exit(1)

# call ffmpeg with the required args
cmd = 'ffmpeg -hide_banner -loglevel error -i "{}" -c:a copy -filter:v "crop={}:{}:{}:{}" {}{}'
cmd = (
'ffmpeg -hide_banner -loglevel error -i "{}" -c:a copy '
'-filter:v "crop={}:{}:{}:{}" {}{}'
)

cmd = cmd.format(
args.input,
width,
Expand Down

0 comments on commit 4f714df

Please sign in to comment.