Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key 1 in SeriesController #1473

Closed
ghost opened this issue Dec 3, 2023 · 6 comments
Closed

Undefined array key 1 in SeriesController #1473

ghost opened this issue Dec 3, 2023 · 6 comments

Comments

@ghost
Copy link

ghost commented Dec 3, 2023

Looks like anything non latin doesn't work right here: https://github.com/NNTmux/newznab-tmux/blob/d25d158ad041be8e371d3d91b10b51ea11f38871/app/Http/Controllers/SeriesController.php#L127C55-L127C55

None of the preg_matches actually work on Chinese of Japanese chars for example.

Can test with this name: たけし城 (2023)

If you change the regex to use \w instead of [A-Z] it matches but then it still cannot find a corresponding A-Z letter obviously so that's probably not the way to go.

One option is to never allow non latin characters in videos table by only picking the english/latin names of shows upon insert (if available) but that won't help existing rows in the table.

Another option is to just ignore I guess:

                    if (!$hits) {
                        continue;
                    }
@DariusIII
Copy link
Member

Maybe something like this could work?

foreach ($masterserieslist as $s) {
                if (preg_match('/^[0-9]/', $s['title'])) {
                    $thisrange = '0-9';
                } else {
                    preg_match('/([\p{L}\p{N}\p{Katakana}\p{Hiragana}\p{Han}]).*/i', $s['title'], $hits);
                    $thisrange = strtoupper($hits[1]);
                }
                $serieslist[$thisrange][] = $s;
            }
            ksort($serieslist);

            $englishRange = range('A', 'Z');
            $hiraganaRange = array_map('mb_convert_encoding', range(0x3041, 0x3096), array_fill(0, 0x3096 - 0x3041 + 1, 'UTF-8'));
            $katakanaRange = array_map('mb_convert_encoding', range(0x30A1, 0x30F6), array_fill(0, 0x30F6 - 0x30A1 + 1, 'UTF-8'));
            $kanjiRange = array_map('mb_convert_encoding', range(0x4E00, 0x9FBF), array_fill(0, 0x9FBF - 0x4E00 + 1, 'UTF-8'));

            $mergedRange = array_merge($englishRange, $hiraganaRange, $katakanaRange, $kanjiRange);

            $this->smarty->assign('serieslist', $serieslist);
            $this->smarty->assign('mergedRange', $mergedRange);
            $this->smarty->assign('seriesletter', $letter);
            $this->smarty->assign('showname', $showname);

@ghost
Copy link
Author

ghost commented Dec 3, 2023

Perhaps but would focus on specific alphabets I guess. For example I dont know if it works with Cyrillic plus all of the letters it groups Series by are latin A-Z + 0-9 so it would not show up anyway I guess?

@DariusIII
Copy link
Member

$cyrillicRange = array_map('mb_convert_encoding', range(0x0400, 0x04FF), array_fill(0, 0x04FF - 0x0400 + 1, 'UTF-8'));

@DariusIII
Copy link
Member

But yeah, this is over complicated and will not yield good results.

Copy link

github-actions bot commented Jan 3, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 3, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant