Fix for season 0
This commit is contained in:
parent
3ff6557f83
commit
3ee1937af5
@ -117,6 +117,11 @@ string encodeUrl( const string &url ) {
|
|||||||
bool searchSpecificSeason( const char_t *const path, size_t &ep_pos,
|
bool searchSpecificSeason( const char_t *const path, size_t &ep_pos,
|
||||||
const string &number ) {
|
const string &number ) {
|
||||||
size_t cur_pos{};
|
size_t cur_pos{};
|
||||||
|
#ifdef _WIN32
|
||||||
|
auto ncompare = wcsncmp;
|
||||||
|
#else
|
||||||
|
auto ncompare = strncmp;
|
||||||
|
#endif
|
||||||
// search for S[0-9]+E[0-9]+
|
// search for S[0-9]+E[0-9]+
|
||||||
while ( path[cur_pos] != '\0' ) {
|
while ( path[cur_pos] != '\0' ) {
|
||||||
if ( ( path[cur_pos] == 's' || path[cur_pos] == 'S' ) &&
|
if ( ( path[cur_pos] == 's' || path[cur_pos] == 'S' ) &&
|
||||||
@ -124,19 +129,18 @@ bool searchSpecificSeason( const char_t *const path, size_t &ep_pos,
|
|||||||
cur_pos++;
|
cur_pos++;
|
||||||
while ( path[cur_pos] == '0' )
|
while ( path[cur_pos] == '0' )
|
||||||
cur_pos++;
|
cur_pos++;
|
||||||
|
// if season number is 0, move back because previous while skipped it
|
||||||
|
if( number == TEXT("0") )
|
||||||
|
cur_pos--;
|
||||||
// make sure season's number is the same as provided in argument
|
// make sure season's number is the same as provided in argument
|
||||||
// `number`
|
// `number`
|
||||||
#ifdef _WIN32
|
if ( !ncompare( path + cur_pos, number.c_str(), number.size() ) ) {
|
||||||
if ( wcsncmp( path + cur_pos, number.c_str(), number.size() ) )
|
cur_pos += number.size();
|
||||||
#else
|
if ( ( path[cur_pos] == 'e' || path[cur_pos] == 'E' ) &&
|
||||||
if ( strncmp( path + cur_pos, number.c_str(), number.size() ) )
|
iswdigit( path[cur_pos + 1] ) ) {
|
||||||
#endif
|
ep_pos = cur_pos + 1;
|
||||||
continue;
|
return true;
|
||||||
cur_pos += number.size();
|
}
|
||||||
if ( ( path[cur_pos] == 'e' || path[cur_pos] == 'E' ) &&
|
|
||||||
iswdigit( path[cur_pos + 1] ) ) {
|
|
||||||
ep_pos = cur_pos + 1;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_pos++;
|
cur_pos++;
|
||||||
|
Loading…
Reference in New Issue
Block a user