Giter VIP home page Giter VIP logo

Comments (14)

xezo360hye avatar xezo360hye commented on May 20, 2024 1

@0next that's strange, it works perfectly fine for me. Could you please upload new debug info with sh -x ani-cli? Can you also verify if it's (α) working when you download instead of playing, and (β) when you preselect the title and episode with -e NUMBER TITLE? Also please enclose your terminal output in back quotes so that it does not appear as a list (since every line starts with + ). By the way, it seems there is some other problem with sed which I noticed just now: it reports error about some "unterminated substitution pattern" while fetching links, but it doesn't break anything so I'll leave it as it is for now, should be investigated later on probably

@port19x since the OP says it doesn't work yet I'll continue working on this and will send pull request when I feel like it this will work for everyone and not just me

from ani-cli.

CoolnsX avatar CoolnsX commented on May 20, 2024

let me spin up my freebsd VM.

from ani-cli.

71zenith avatar 71zenith commented on May 20, 2024

we had this issue before. the bsd cut does not act identical to gnu variant

from ani-cli.

CoolnsX avatar CoolnsX commented on May 20, 2024

ah, yes it's there in logs sent above

printf %s wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes)
cut -f1 #this didn't work properly on BSD
id=wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes) #should be wm2zBXuqhdKM7L7AL
episodes_list wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes) #should be wm2zBXuqhdKM7L7AL
ep_list=
[ -z ]
printf %s
nth Select episode: -m
ep_no=
[ -z ]
exit 1

from ani-cli.

port19x avatar port19x commented on May 20, 2024

ah, yes it's there in logs sent above

printf %s wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes)
cut -f1 #this didn't work properly on BSD
id=wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes) #should be wm2zBXuqhdKM7L7AL
episodes_list wm2zBXuqhdKM7L7ALtSerial Experiments Lain (13 episodes) #should be wm2zBXuqhdKM7L7AL
ep_list=
[ -z ]
printf %s
nth Select episode: -m
ep_no=
[ -z ]
exit 1

Can you check if it works with a space? Like cut -f 1
I'm surprised we don't have spaces in there

from ani-cli.

port19x avatar port19x commented on May 20, 2024

From man 1p cut
image

from ani-cli.

xezo360hye avatar xezo360hye commented on May 20, 2024

Hey there, another OpenBSD user out there, after a few hours of debugging I see that the first cause is not the cut itself but rather sed on line 190 which uses \t to insert tab, on which the next cut relies. While it works everywhere else, it somehow does not on OpenBSD, since \t inserts literal letter t there. If I replace it manually with actual tab symbol the next error appears from a similar cause on lines 197, 190, 141, 130, 120 and 116, where \n is used to insert newline. Here the fix would be to use \ and actual newline instead of \n, like this:

# Before
sed 's|,|\n|g; s|"||g'
# After
sed 's|,|\
|g; s|"||g'

Also seems like grep isn't doing well with escaped characters either, so I replaced \s with [[:space:]] on line 26. Everything tested on the latest commit e90dd8b on branch master. Below is the diff which sums this all up, I'd make a pull request but not sure if these changes will work on other platforms (and I kinda don't want to test this rn, might do in a few days on different Linux distros) or if there is a more elegant way around this issue since these newlines look really ugly to me at least

--- ani-cli     Wed Feb 14 16:10:37 2024
+++ ani-cli-fixed       Wed Feb 14 16:09:51 2024
@@ -23,7 +23,7 @@
     multi_flag=""
     [ $# -ne 1 ] && shift && multi_flag="$1"
     line=$(printf "%s" "$stdin" | cut -f1,3 | tr '\t' ' ' | launcher "$multi_flag" "$prompt" | cut -d " " -f 1)
-    [ -n "$line" ] && printf "%s" "$stdin" | grep -E '^'"${line}"'($|\s)' | cut -f2,3 || exit 1
+    [ -n "$line" ] && printf "%s" "$stdin" | grep -E '^'"${line}"'($|[[:space:]])' | cut -f2,3 || exit 1
 }
 
 die() {
@@ -113,11 +113,14 @@
 
 # extract the video links from reponse of embed urls, extract mp4 links form m3u8 lists
 get_links() {
-    episode_link="$(curl -e "$allanime_refr" -s "https://${allanime_base}$*" -A "$agent" | sed 's|},{|\n|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
+    episode_link="$(curl -e "$allanime_refr" -s "https://${allanime_base}$*" -A "$agent" | sed 's|},{|\
+|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
+
     case "$episode_link" in
         *repackager.wixmp.com*)
             extract_link=$(printf "%s" "$episode_link" | cut -d'>' -f2 | sed 's|repackager.wixmp.com/||g;s|\.urlset.*||g')
-            for j in $(printf "%s" "$episode_link" | sed -nE 's|.*/,([^/]*),/mp4.*|\1|p' | sed 's|,|\n|g'); do
+            for j in $(printf "%s" "$episode_link" | sed -nE 's|.*/,([^/]*),/mp4.*|\1|p' | sed 's|,|\
+|g'); do
                 printf "%s >%s\n" "$j" "$extract_link" | sed "s|,[^/]*|${j}|g"
             done | sort -nr
             ;;
@@ -127,7 +130,8 @@
             else
                 extract_link=$(printf "%s" "$episode_link" | head -1 | cut -d'>' -f2)
                 relative_link=$(printf "%s" "$extract_link" | sed 's|[^/]*$||')
-                curl -e "$allanime_refr" -s "$extract_link" -A "$agent" | sed 's|^#.*x||g; s|,.*|p|g; /^#/d; $!N; s|\n| >|' | sed "s|>|>${relative_link}|g" | sort -nr
+                curl -e "$allanime_refr" -s "$extract_link" -A "$agent" | sed 's|^#.*x||g; s|,.*|p|g; /^#/d; $!N; s|\
+| >|' | sed "s|>|>${relative_link}|g" | sort -nr
             fi
             ;;
         *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;;
@@ -138,7 +142,8 @@
 # innitialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link
 provider_init() {
     provider_name=$1
-    provider_id=$(printf "%s" "$resp" | sed -n "$2" | head -1 | cut -d':' -f2 | sed 's/../&\n/g' | sed 's/^01$/9/g;s/^08$/0/g;s/^05$/=/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^07$/?/g;s/^00$/8/g;s/^5c$/d/g;s/^0f$/7/g;s/^5e$/f/g;s/^17$/\//g;s/^54$/l/g;s/^09$/1/g;s/^48$/p/g;s/^4f$/w/g;s/^0e$/6/g;s/^5b$/c/g;s/^5d$/e/g;s/^0d$/5/g;s/^53$/k/g;s/^1e$/\&/g;s/^5a$/b/g;s/^59$/a/g;s/^4a$/r/g;s/^4c$/t/g;s/^4e$/v/g;s/^57$/o/g;s/^51$/i/g;' | tr -d '\n' | sed "s/\/clock/\/clock\.json/")
+    provider_id=$(printf "%s" "$resp" | sed -n "$2" | head -1 | cut -d':' -f2 | sed 's/../&\
+/g' | sed 's/^01$/9/g;s/^08$/0/g;s/^05$/=/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^07$/?/g;s/^00$/8/g;s/^5c$/d/g;s/^0f$/7/g;s/^5e$/f/g;s/^17$/\//g;s/^54$/l/g;s/^09$/1/g;s/^48$/p/g;s/^4f$/w/g;s/^0e$/6/g;s/^5b$/c/g;s/^5d$/e/g;s/^0d$/5/g;s/^53$/k/g;s/^1e$/\&/g;s/^5a$/b/g;s/^59$/a/g;s/^4a$/r/g;s/^4c$/t/g;s/^4e$/v/g;s/^57$/o/g;s/^51$/i/g;' | tr -d '\n' | sed "s/\/clock/\/clock\.json/")
 }
 
 # generates links based on given provider
@@ -187,14 +192,16 @@
 search_anime() {
     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 "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"search\":{\"allowAdult\":false,\"allowUnknown\":false,\"query\":\"$1\"},\"limit\":40,\"page\":1,\"translationType\":\"$mode\",\"countryOrigin\":\"ALL\"}" --data-urlencode "query=$search_gql" -A "$agent" | sed 's|Show|\n|g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"([^\"]*)\".*${mode}\":([1-9][^,]*).*|\1\t\2 (\3 episodes)|p"
+    curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"search\":{\"allowAdult\":false,\"allowUnknown\":false,\"query\":\"$1\"},\"limit\":40,\"page\":1,\"translationType\":\"$mode\",\"countryOrigin\":\"ALL\"}" --data-urlencode "query=$search_gql" -A "$agent" | sed 's|Show|\
+|g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"([^\"]*)\".*${mode}\":([1-9][^,]*).*|\1       \2 (\3 episodes)|p"
 }
 
 # get the episodes list of the selected anime
 episodes_list() {
     episodes_list_gql="query (\$showId: String!) {    show(        _id: \$showId    ) {        _id availableEpisodesDetail    }}"
 
-    curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$*\"}" --data-urlencode "query=$episodes_list_gql" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\n|g; s|"||g' | sort -n -k 1
+    curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$*\"}" --data-urlencode "query=$episodes_list_gql" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\
+|g; s|"||g' | sort -n -k 1
 }
 
 # PLAYING

from ani-cli.

xezo360hye avatar xezo360hye commented on May 20, 2024

@0next please let me know if this solution worked for you as well

from ani-cli.

port19x avatar port19x commented on May 20, 2024

Thank you for investigating.
Please consider making a pull request, we can do linux testing for you.
The diff doesn't seem so large that this would be much of an undertaking.

from ani-cli.

0next avatar 0next commented on May 20, 2024

@xezo360hye sorry for the late reply, I've tested the new patch, and it seems to get farther, however doesn't work still.. It now shows fzf, and prompts for what anime I want to watch, but gives me numbers for choice.. And quits right after..

from ani-cli.

0next avatar 0next commented on May 20, 2024

Here's the output of sh -x ani-cli lain:

  • version_number=4.8.0
  • 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
  • uname -a
  • player_function=mpv
  • no_detach=0
  • use_external_menu=0
  • skip_intro=0
  • skip_title=
  • [ -t 0 ]
  • hist_dir=/home/myUser/.local/state/ani-cli
  • [ ! -d /home/myUser/.local/state/ani-cli ]
  • histfile=/home/myUser/.local/state/ani-cli/ani-hsts
  • [ ! -f /home/myUser/.local/state/ani-cli/ani-hsts ]
  • search=scrape
  • [ 1 -gt 0 ]
  • printf %s lain
  • sed s|^ ||;s| |+|g
  • query=lain
  • shift
  • [ 0 -gt 0 ]
  • [ 0 = 0 ]
  • multi_selection_flag=-m
  • [ 0 = 1 ]
  • printf \33[2K\r\033[1;34mChecking dependencies...\033[0m\n
    Checking dependencies...
  • dep_ch curl sed grep
  • [ 0 = 1 ]
  • [ -z ]
  • dep_ch fzf
  • dep_ch mpv
  • [ 0 = 0 ]
  • [ -z lain ]
  • printf %s lain
  • sed s| |+|g
  • query=lain
  • search_anime lain
  • anime_list=iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
    HK4yoi5Q5KxYA4Bwv Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (13 episodes)
    jyYQojecWayF54B6X Tondemo Skill de Isekai Hourou Meshi (12 episodes)
    RpxzEd2y3vx3T9ndm Gaikotsu Kishi-sama, Tadaima Isekai e Odekakechuu (12 episodes)
    y2Q8ZFgkjjdzxYQgS Sekai Saikou no Ansatsusha, Isekai Kizoku ni Tensei suru (12 episodes)
    4iv3gmvQyuDXK33nd Death March kara Hajimaru Isekai Kyousoukyoku (12 episodes)
    wm2zBXuqhdKM7L7AL Serial Experiments Lain (13 episodes)
  • [ -z iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
    HK4yoi5Q5KxYA4Bwv Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (13 episodes)
    jyYQojecWayF54B6X Tondemo Skill de Isekai Hourou Meshi (12 episodes)
    RpxzEd2y3vx3T9ndm Gaikotsu Kishi-sama, Tadaima Isekai e Odekakechuu (12 episodes)
    y2Q8ZFgkjjdzxYQgS Sekai Saikou no Ansatsusha, Isekai Kizoku ni Tensei suru (12 episodes)
    4iv3gmvQyuDXK33nd Death March kara Hajimaru Isekai Kyousoukyoku (12 episodes)
    wm2zBXuqhdKM7L7AL Serial Experiments Lain (13 episodes) ]
  • [ -eq ]
  • 2> /dev/null
  • printf %s iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
    HK4yoi5Q5KxYA4Bwv Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (13 episodes)
    jyYQojecWayF54B6X Tondemo Skill de Isekai Hourou Meshi (12 episodes)
    RpxzEd2y3vx3T9ndm Gaikotsu Kishi-sama, Tadaima Isekai e Odekakechuu (12 episodes)
    y2Q8ZFgkjjdzxYQgS Sekai Saikou no Ansatsusha, Isekai Kizoku ni Tensei suru (12 episodes)
    4iv3gmvQyuDXK33nd Death March kara Hajimaru Isekai Kyousoukyoku (12 episodes)
    wm2zBXuqhdKM7L7AL Serial Experiments Lain (13 episodes)
  • sed -n p
  • result=iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
    HK4yoi5Q5KxYA4Bwv Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (13 episodes)
    jyYQojecWayF54B6X Tondemo Skill de Isekai Hourou Meshi (12 episodes)
    RpxzEd2y3vx3T9ndm Gaikotsu Kishi-sama, Tadaima Isekai e Odekakechuu (12 episodes)
    y2Q8ZFgkjjdzxYQgS Sekai Saikou no Ansatsusha, Isekai Kizoku ni Tensei suru (12 episodes)
    4iv3gmvQyuDXK33nd Death March kara Hajimaru Isekai Kyousoukyoku (12 episodes)
    wm2zBXuqhdKM7L7AL Serial Experiments Lain (13 episodes)
  • [ -z ]
  • nl -w 2
  • printf %s iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
    HK4yoi5Q5KxYA4Bwv Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (13 episodes)
    jyYQojecWayF54B6X Tondemo Skill de Isekai Hourou Meshi (12 episodes)
    RpxzEd2y3vx3T9ndm Gaikotsu Kishi-sama, Tadaima Isekai e Odekakechuu (12 episodes)
    y2Q8ZFgkjjdzxYQgS Sekai Saikou no Ansatsusha, Isekai Kizoku ni Tensei suru (12 episod+ nth Select anime:
  • sed s/^[[:space:]]//
    es)
    4iv3gmvQyuDXK33nd Death March kara Hajimaru Isekai Kyousoukyoku (12 episodes)
    wm2zBXuqhdKM7L7AL Serial Experiments Lain (13 episodes)
  • result=iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • [ -z iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes) ]
  • printf %s iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • cut -f2
  • title=iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • tr -d [:punct:]
  • printf %s iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • cut -d( -f1
  • allanime_title=iYwbaywiQ86vCc3cf Seija Musou Salaryman Isekai de Ikinokoru Tame ni Ayumu Michi
  • printf %s iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • cut -f1
  • id=iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • episodes_list iYwbaywiQ86vCc3cf Seija Musou: Salaryman, Isekai de Ikinokoru Tame ni Ayumu Michi (12 episodes)
  • ep_list=
  • [ -z ]
  • printf %s
  • nth Select episode: -m
  • ep_no=
  • [ -z ]
  • exit 1

from ani-cli.

xezo360hye avatar xezo360hye commented on May 20, 2024

Yeah I see why it's happening now, for some reasons GitHub decided to replace a literal tab character with multiple spaces in my diff. Thank you so much, piece of broken software. @0next check out my PR #1296 and try it out, should be fine now since cut -f1 relies on that tab

from ani-cli.

0next avatar 0next commented on May 20, 2024

Nice job! That worked perfectly! Just to be sure I tested it on my T400 running Arch; it worked fine as well! 👍
Now we just need to push the edits...

from ani-cli.

port19x avatar port19x commented on May 20, 2024

Thanks for confirming @0next

from ani-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.