Skip to content

Commit

Permalink
Make --import work again
Browse files Browse the repository at this point in the history
  • Loading branch information
allejok96 committed Mar 21, 2021
1 parent 768387a commit 560f1a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jwb-index
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ p.add_argument('positional_arguments', nargs='*', metavar='DIR|FILE|COMMAND',

s = p.parse_args(namespace=Settings())

if not (s.mode or s.download or s.download_subtitles):
# Required arguments
if not (s.mode or s.download or s.download_subtitles or s.import_dir):
msg('please use --mode or --download')
exit(1)

Expand Down
17 changes: 12 additions & 5 deletions jwlib/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


class File:
def __init__(self, name: str, directory: str):
self.name = name
self.path = os.path.join(directory, name)
def __init__(self, directory: str, filename: str):
self.name = filename
self.path = os.path.join(directory, filename)
try:
stat = os.stat(self.path)
self.size = stat.st_size
Expand All @@ -18,15 +18,22 @@ def __init__(self, name: str, directory: str):
self.size = None
self.date = None

def isfile(self):
return os.path.isfile(self.path)

def ismp4(self):
return self.path.lower().endswith('.mp4')


def copy_files(s: Settings):
dest_dir = os.path.join(s.work_dir, s.sub_dir)

# Create a list of all mp4 files to be copied
source_files = []
for name in os.listdir(s.import_dir):
if not name.lower().endswith('.mp4'):
continue
source_file = File(s.import_dir, name)
if not source_file.isfile() or not source_file.ismp4():
continue
dest_file = File(dest_dir, name)
# Just a simple size check, no checksum etc
if source_file.size != dest_file.size:
Expand Down

0 comments on commit 560f1a5

Please sign in to comment.