Skip to content

Commit abbcd67

Browse files
committed
add audio/video subcategorization
1 parent 1034ca5 commit abbcd67

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

pythonbits/bb.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,20 @@ def confirm_finalization(self, fields):
6161
fields or self.default_fields)
6262

6363
def subcategory(self):
64-
# only video for now
65-
return VideoSubmission
64+
files = []
65+
for root, _, fs in os.walk(self['path']):
66+
for f in fs:
67+
fpath = os.path.join(root, f)
68+
files.append((os.path.getsize(fpath), fpath))
69+
70+
for size, path in sorted(files, reverse=True):
71+
mime_guess, _ = guess_type(path)
72+
if mime_guess:
73+
mime_guess = mime_guess.split('/')
74+
if mime_guess[0] == 'video':
75+
return VideoSubmission
76+
elif mime_guess[0] == 'audio':
77+
return AudioSubmission
6678

6779
def subcategorise(self):
6880
log.debug('Attempting to narrow category')

0 commit comments

Comments
 (0)