- int i_prio = 0;
- if( !i_prio && !strcmp( tmp_fname_trim, f_fname_trim ) )
- {
- /* matches the movie name exactly */
- i_prio = 4;
- }
- if( !i_prio &&
- ( tmp = strstr( tmp_fname_trim, f_fname_trim ) ) )
- {
- /* contains the movie name */
- tmp += strlen( f_fname_trim );
- if( whiteonly( tmp ) )
- {
- /* chars in front of the movie name */
- i_prio = 2;
- }
- else
- {
- /* chars after (and possibly in front of)
- * the movie name */
- i_prio = 3;
- }
- }
- if( !i_prio )
- {
- /* doesn't contain the movie name */
- if( j == 0 ) i_prio = 1;
- }
-
- if( i_prio >= fuzzy.i_int )
- {
- sprintf( tmpresult, "%s%s", j == -1 ? f_dir : *subdirs,
- de->d_name );
- msg_Dbg( p_this, "autodetected subtitle: %s with "
- "priority %d", de->d_name, i_prio );
- if( ( f = fopen( tmpresult, "rt" ) ) )
- {
- fclose( f );
- result[i_sub_count].priority = i_prio;
- result[i_sub_count].psz_fname = strdup(tmpresult);
- result[i_sub_count].psz_ext = strdup(tmp_fname_ext);
- i_sub_count++;
- }
- }