def parse_episode_identifier(ep_id):
 error = None
 identified_by = None
 if isinstance(ep_id, int):
  if (ep_id <= 0):
   error = u'sequence type episode must be higher than 0'
  identified_by = u'sequence'
 elif re.match(u'(?i)^S\\d{1,4}E\\d{1,3}$', ep_id):
  identified_by = u'ep'
 elif re.match(u'\\d{4}-\\d{2}-\\d{2}', ep_id):
  identified_by = u'date'
 else:
  try:
   ep_id = int(ep_id)
   if (ep_id <= 0):
    error = u'sequence type episode must be higher than 0'
   identified_by = u'sequence'
  except ValueError:
   error = (u'`%s` is not a valid episode identifier.' % ep_id)
 if error:
  raise ValueError(error)
 return identified_by

def parse_episode_identifier ( ep_id ) : error = None identified_by = None if isinstance ( ep_id , int ) : if ( ep_id <= 0 ) : error = u'sequence type episode must be higher than 0' identified_by = u'sequence' elif re . match ( u'(?i)^S\\d{1,4}E\\d{1,3}$' , ep_id ) : identified_by = u'ep' elif re . match ( u'\\d{4}-\\d{2}-\\d{2}' , ep_id ) : identified_by = u'date' else : try : ep_id = int ( ep_id ) if ( ep_id <= 0 ) : error = u'sequence type episode must be higher than 0' identified_by = u'sequence' except ValueError : error = ( u'`%s` is not a valid episode identifier.' % ep_id ) if error : raise ValueError ( error ) return identified_by
parses series episode identifier .