Skip to content

Commit

Permalink
feat: added inputfile argument (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Sep 21, 2023
1 parent dbc8dae commit 45242df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ By default, the program will write to or read from `batch_encoder.ini` in the us

Example: `C:\Users\Kyrch\AppData\Local\AnimeThemes\batch_encoder\batch_encoder.ini`

**Input File**

`--inputfile` will give the option to insert input files in advance, separated by two commas. Example: `python -m batch_encoder -g --inputfile 'source file.mkv,,source file 2.mkv'`.

**Audio Filters**

* `Exit` Saves audio filters if selected and continues script execution.
Expand Down
23 changes: 14 additions & 9 deletions batch_encoder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def main():
help='Name of config file (default: batch_encoder.ini)\n'
'If the file does not exist, default configuration will be written\n'
'The file is expected to exist in the same directory as this script')
parser.add_argument('--inputfile', nargs='?', help='Set the input files separated by two commas')
parser.add_argument('--loglevel', nargs='?', default='info', choices=['debug', 'info', 'error'],
help='Set logging level')
args = parser.parse_args()
Expand Down Expand Up @@ -89,19 +90,23 @@ def main():

# Generate commands from source file candidates in current directory
if mode == 1 or mode == 3:
source_file_candidates = [f for f in os.listdir('.') if f.endswith(tuple(encoding_config.allowed_filetypes))]
if args.inputfile is None:
source_file_candidates = [f for f in os.listdir('.') if f.endswith(tuple(encoding_config.allowed_filetypes))]

if not source_file_candidates:
logging.error('No source file candidates in current directory')
sys.exit()
if not source_file_candidates:
logging.error('No source file candidates in current directory')
sys.exit()

source_files = Interface.choose_source_files(source_file_candidates)
else:
source_files = args.inputfile.split(',,')

source_file_candidates = Interface.choose_source_files(source_file_candidates)
source_file = {}
source_file_info = {}

for source_file_candidate in source_file_candidates:
source_file[source_file_candidate] = SourceFile.from_file(source_file_candidate, encoding_config)
for source_file in source_files:
source_file_info[source_file] = SourceFile.from_file(source_file, encoding_config)

for file, file_value in source_file.items():
for file, file_value in source_file_info.items():
try:
is_collector_valid = False
seek_collector = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='animethemes-batch-encoder',
version='2.0',
version='2.1',
author='AnimeThemes',
author_email='admin@animethemes.moe',
url='https://github.com/AnimeThemes/animethemes-batch-encoder',
Expand Down

0 comments on commit 45242df

Please sign in to comment.