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

Wrong anime title due to wrong extraction from regex caused by escaped ". #1391

Open
0WN463 opened this issue Aug 5, 2024 · 2 comments
Open
Assignees
Labels
category: parsing When the regex doesn't regex priority 2: medium Default for bugs type: bug something isn't working

Comments

@0WN463
Copy link
Contributor

0WN463 commented Aug 5, 2024

Make sure you are on the latest version by running ani-cli -U

Metadata (please complete the following information)
Version: 4.8.11
OS: Arch Linux
Shell: zsh
Anime: [e.g. flcl] (if applicable) Oshi no Ko Season 2

Describe the bug
Oshi no Ko Season 2's title is bugged.

It says

1 \ (5 Episodes)

Steps To Reproduce

  1. Run ani-cli Oshi
  2. First episode on the list is bugged

Expected behavior
Title should appear normally

Additional context
Looking through the script, it seems like the JSON is

          "name": "\"Oshi no Ko\" Season 2",

And the escaped " is being treated wrongly and thus the wrong title is being extracted

@0WN463 0WN463 added priority 2: medium Default for bugs type: bug something isn't working labels Aug 5, 2024
@port19x port19x added the category: parsing When the regex doesn't regex label Aug 8, 2024
@port19x port19x self-assigned this Aug 8, 2024
@port19x
Copy link
Collaborator

port19x commented Aug 10, 2024

Reproduced

+ version_number=4.8.11
+ agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0'
+ allanime_refr=https://allanime.to
+ allanime_base=allanime.day
+ allanime_api=https://api.allanime.day
+ mode=sub
+ download_dir=.
+ quality=best
+ case "$(uname -a)" in
++ uname -a
+ player_function=iina
+ no_detach=0
+ exit_after_play=0
+ use_external_menu=0
+ skip_intro=0
+ skip_title=
+ '[' -t 0 ']'
+ hist_dir=/Users/port19/.local/state/ani-cli
+ '[' '!' -d /Users/port19/.local/state/ani-cli ']'
+ histfile=/Users/port19/.local/state/ani-cli/ani-hsts
+ '[' '!' -f /Users/port19/.local/state/ani-cli/ani-hsts ']'
+ search=scrape
+ '[' 1 -gt 0 ']'
+ case "$1" in
++ printf %s ' Oshi no Ko'
++ sed 's|^ ||;s| |+|g'
+ query=Oshi+no+Ko
+ shift
+ '[' 0 -gt 0 ']'
+ '[' 0 = 0 ']'
+ multi_selection_flag=-m
+ '[' 0 = 1 ']'
+ printf '\33[2K\r\033[1;34mChecking dependencies...\033[0m\n'
+ dep_ch curl sed grep
+ for dep in '"$@"'
+ command -v curl
+ for dep in '"$@"'
+ command -v sed
+ for dep in '"$@"'
+ command -v grep
+ '[' 0 = 1 ']'
+ '[' -z '' ']'
+ dep_ch fzf
+ for dep in '"$@"'
+ command -v fzf
+ case "$player_function" in
+ dep_ch iina
+ for dep in '"$@"'
+ command -v iina
+ case "$search" in
+ '[' 0 = 0 ']'
+ '[' -z Oshi+no+Ko ']'
+ '[' scrape = nextep ']'
++ printf %s Oshi+no+Ko
++ sed 's| |+|g'
+ query=Oshi+no+Ko
++ search_anime Oshi+no+Ko
++ search_gql='query(        $search: SearchInput        $limit: Int        $page: Int        $translationType: VaildTranslationTypeEnumType        $countryOrigin: VaildCountryOriginEnumType    ) {    shows(        search: $search        limit: $limit        page: $page        translationType: $translationType        countryOrigin: $countryOrigin    ) {        edges {            _id name availableEpisodes __typename       }    }}'
++ curl -e https://allanime.to -s -G https://api.allanime.day/api --data-urlencode 'variables={"search":{"allowAdult":false,"allowUnknown":false,"query":"Oshi+no+Ko"},"limit":40,"page":1,"translationType":"sub","countryOrigin":"ALL"}' --data-urlencode 'query=query(        $search: SearchInput        $limit: Int        $page: Int        $translationType: VaildTranslationTypeEnumType        $countryOrigin: VaildCountryOriginEnumType    ) {    shows(        search: $search        limit: $limit        page: $page        translationType: $translationType        countryOrigin: $countryOrigin    ) {        edges {            _id name availableEpisodes __typename       }    }}' -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0'
++ sed 's|Show|\
|g'
++ sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":([1-9][^,]*).*|\1	\2 (\3 episodes)|p'
+ anime_list='pxoBGA54cmpk56MLA	\ (6 episodes)
b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)'
+ '[' -z 'pxoBGA54cmpk56MLA	\ (6 episodes)
b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)' ']'
+ '[' '' -eq '' ']'
+ '[' -z '' ']'
++ printf %s 'pxoBGA54cmpk56MLA	\ (6 episodes)
b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)'
++ nl -w 2
++ sed 's/^[[:space:]]//'
++ nth 'Select anime: '
+++ cat -
++ stdin='1	pxoBGA54cmpk56MLA	\ (6 episodes)
2	b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)'
++ '[' -z '1	pxoBGA54cmpk56MLA	\ (6 episodes)
2	b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)' ']'
+++ printf '%s\n' '1	pxoBGA54cmpk56MLA	\ (6 episodes)
2	b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)'
+++ wc -l
+++ tr -d '[:space:]'
++ line_count=2
++ '[' 2 -eq 1 ']'
++ prompt='Select anime: '
++ multi_flag=
++ '[' 1 -ne 1 ']'
+++ printf %s '1	pxoBGA54cmpk56MLA	\ (6 episodes)
2	b3u5TprKSKHBPBcor	[Oshi no Ko] (12 episodes)'
+++ cut -f1,3
+++ tr '\t' ' '
+++ launcher '' 'Select anime: '
+++ '[' 0 = 0 ']'
+++ '[' -z '' ']'
+++ set -- +m 'Select anime: '
+++ '[' 0 = 0 ']'
+++ fzf +m --reverse --cycle --prompt 'Select anime: '
+++ cut -d ' ' -f 1
+++ '[' 0 = 1 ']'
++ line=
++ '[' -n '' ']'
++ exit 1
+ result=
+ '[' -z '' ']'
+ exit 1

@71zenith
Copy link
Collaborator

One very quick solution would be to change the regex to "name":"(.+)",".*{mode}": (only the relevant portion) instead of "name\":\"([^\"]*)\".*${mode}\"

HirschBerge added a commit to HirschBerge/improve_error_msg that referenced this issue Oct 6, 2024
in pystardust#1391 I used 71zenith's recommendation for fixing quotes escaped.
Tested and working with Oshi No Ko's Second season.
likely because it's hard to be consistent with the way 「押しの子」is shown in
English.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: parsing When the regex doesn't regex priority 2: medium Default for bugs type: bug something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants