Skip to content

Commit 36c5f9d

Browse files
committed
Revert "Add "confirmed_guess" that asks user"
This reverts commit 88db757 Fix style of video type pass to guessit
1 parent de0b20a commit 36c5f9d

1 file changed

Lines changed: 19 additions & 50 deletions

File tree

pythonbits/bb.py

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -213,44 +213,7 @@ class VideoSubmission(BbSubmission):
213213
default_fields = BbSubmission.default_fields
214214

215215
def _render_guess(self):
216-
if isinstance(self, TvSubmission):
217-
type = 'episode'
218-
guess = guessit.guessit(self['path'], options=('--type', 'episode'))
219-
elif isinstance(self, MovieSubmission):
220-
guess = guessit.guessit(self['path'], options=('--type', 'movie'))
221-
else:
222-
guess = guessit.guessit(self['path'])
223-
return dict(guess)
224-
225-
def _render_confirmed_guess(self):
226-
# If there are any inconsistencies in the information from guess it
227-
# (e.g. type="episode" but no "season"), ask the user.
228-
guess = self['guess']
229-
print('Confirm by pressing enter or type in correct values:')
230-
231-
# Confirm detected title
232-
guess['title'] = input('Guessed title: %s > ' % (guess['title'],)) or guess['title']
233-
234-
# Confirm detected type (movie or episode)
235-
confirmed_type = None
236-
while confirmed_type not in ('movie', 'episode'):
237-
user_type = 'tv' if guess['type'] == 'episode' else guess['type']
238-
confirmed_type = (input('Guessed type ("movie" or "tv"): %s > ' % (user_type,))
239-
or guess['type'])
240-
confirmed_type = 'episode' if confirmed_type == 'tv' else confirmed_type
241-
guess['type'] = confirmed_type
242-
243-
# Get missing season if applicable
244-
if guess['type'] == 'episode' and 'season' not in guess:
245-
while True:
246-
try:
247-
guess['season'] = int(input('Season > '))
248-
except (ValueError, TypeError):
249-
pass
250-
else:
251-
break
252-
253-
return guess
216+
return dict(guessit.guessit(self['path']))
254217

255218
def subcategory(self):
256219
if type(self) == VideoSubmission:
@@ -282,18 +245,16 @@ def _render_tv_specifier(self):
282245

283246
# todo: test tv show name from title_arg, but episode from filename
284247

285-
# Try autodetection first, fall back to user prompts if values look fishy
286-
for key in ('guess', 'confirmed_guess'):
287-
guess = self.__getitem__(key)
288-
log.debug('Guess: %s' % (guess,))
289-
if guess['type'] == 'episode':
290-
if self['title_arg']:
291-
title = self['title_arg']
292-
else:
293-
title = guess['title']
294-
if 'season' in guess:
295-
return TvSpecifier(title, guess['season'],
296-
guess.get('episode', None))
248+
guess = self['guess']
249+
if guess['type'] == 'episode':
250+
if self['title_arg']:
251+
title = self['title_arg']
252+
else:
253+
title = guess['title']
254+
return TvSpecifier(title, guess['season'],
255+
guess.get('episode', None))
256+
257+
raise Exception('Unable to guess TV show')
297258

298259
@form_field('tags')
299260
def _render_tags(self):
@@ -572,6 +533,10 @@ class TvSubmission(VideoSubmission):
572533
'form_description': ('desc', 'text'),
573534
}
574535

536+
def _render_guess(self):
537+
return dict(guessit.guessit(self['path'],
538+
options=('--type', 'episode')))
539+
575540
def _render_search_title(self):
576541
return self['tv_specifier'].title
577542

@@ -700,6 +665,10 @@ class MovieSubmission(VideoSubmission):
700665
'screenshots': (lambda i, v: 'screenshot' + str(i + 1), 'text'),
701666
}
702667

668+
def _render_guess(self):
669+
return dict(guessit.guessit(self['path'],
670+
options=('--type', 'movie')))
671+
703672
def _render_search_title(self):
704673
if self['title_arg']:
705674
return self['title_arg']

0 commit comments

Comments
 (0)