RaitaroH / adl

🍿 anime scraper/downloader + trackma wrapper
GNU General Public License v3.0
135 stars 15 forks source link

trackma > fzf gets cutoff in small terminal sizes #44

Closed Darukutsu closed 1 year ago

Darukutsu commented 1 year ago

When having smaller sizes of terminal, output is not properly displayed due to its length. Maybe getting rid of excess dots or switching position of elements...

image

I didn't read through the whole code, this will break scraping.

Some of the ideas:

entry="$(echo "$tlist" | sed 's#\(.*\)\(\. \+[0-9]\+ / [0-9]\+ \+ [0-9]\+\)#\2\1#g' | sed 's#[0-9]\+|#|#g' | sed 's#\. \+|##g' | sed 's#\.##g' | fzf_select | process_list)"

image

entry="$(echo "$tlist" | sed 's#\(\. \+[0-9]\+ / [0-9]\+ \+[0-9]\+\)\|\.\||##g' | fzf_select | process_list)"

image

Or maybe come with other solutions since trackma is displaying list correctly with any sizes: image

I don't think it's important at all. I personally like trackma style.

RaitaroH commented 1 year ago

Hmm, Well there is a bit of history in regards to this actually. See issue #9 The workaround was to specify to trackma how big the output has to be; in watching cases is this line: https://github.com/RaitaroH/adl/blob/4e95346fbc215af40b68b81652685b6b321e79ab/adl#L191

So if I remove the LINES and COLUMNS I get the trackma default, which can still be too wide. As such the COLUMN has to be changed manually, but you see... then it looks kinda cramped on bigger terminal sizes. For simplicity I can suggest to you to simply change the COLUMNS value to fit your needs.

I like your approach to change how the output looks like in the first place, though this will also require changes in other places like process_list, frece, and exception checking (some anime have . at the end of their names). If you are capable, please make a PR; I might look into this as well.

So you know, I have opened an issue on trackma side: https://github.com/z411/trackma/issues/660 I don't know python to be able to make a PR for trackma itself, which would solve the exception issue.

Darukutsu commented 1 year ago

Well, this is weird when we do something like this in terminal, output will be formatted: image

but redirecting output, piping it etc. will break formatting: image image image

This is certainly problem of some python code in trackma.

Anyway, I was thinking about some solutions and possibly we could do:

tlist=$(LINES=25 COLUMNS=$(tput cols) trackma -a "$account" list | head -n -2 | tail -n +2)

this will work in cases when name isn't cut (red ones): image

A workaround could be using arrays instead of variable to store values. For example, formatted array with tput will be printed and then search will be provided with "$arr2[n]" in watch(). I will try something, if it works, I open PR.

RaitaroH commented 1 year ago

Most certainly the tput cols option does not work. The name is truncated not just in fzf, but overall. As such streams and especially local folders will not work properly.

I am not opposed to the idea of processing the trackma output before sending in to fzf as in your previous example. If we do this then the process_list function has to change. So it will be more like:

entry="$(echo "$tlist" | process_list | fzf_select)"

or even

entry="$(echo "$tlist" | pre_process_list | fzf_select | post_process_list)"

Like in your example. Just that in this case process_list simply has to change.

entry="$(echo "$tlist" | sed 's#\(\. \+[0-9]\+ / [0-9]\+ \+[0-9]\+\)\|\.\||##g' | fzf_select | process_list)"

This processing should also take in consideration the exceptions array.


Alternatively we could take inspiration from this: https://github.com/justchokingaround/trackma-wrapper. In this case he is using this function, which we just need the index from trackma. This also solves my exceptions workaround:

trackma -a 1 info "1" | head -n1

Initially I was against this as trackma can be rather slow in my experience. Not sure why, maybe python. Pre-caching the info also kinda doesn't work on larger lists, as the initial creation will be very very slow.

I personally think a combination of this 2 things can be the solution to this issue. Also yeah, I am very aware of the weirdness when | or > or tee-ing the output.

Darukutsu commented 1 year ago

What do you think about output? I tried Hige Wo Soru... it's playing image

image

process_list()    {
  #perl -pe 's/\x1b\[[0-9;]*m//g ; s/^.+?[^\s]\s+(.+?(?=\.\.))\.+\ +(\d+).[^\d]\ (\d+|\?)\s+(\d*[.]?\d+).+$/\1|\2|\3|\4|/g'
  perl -pe 's/^.+? +(\d+) \/ (\d+) +(\d) +(.*)/\4|\1|\2|\3|/g'
}
...
pre_process_list() {
  # not sure if use \d or [[:digit:]] or [0-9] POSIX reasons...
  # https://unix.stackexchange.com/a/414230/482125
  # or maybe switch to perl since this piping is one big mess

  #@1
  sed 's#^\(| \+\)#@#' |\
  # move end stats after @1 but before name
  sed 's#\(@.*\.\)\(\. \+[0-9]\+ / [0-9]\+ \+ [0-9]\+\)#\2\1#' |\
  sed 's#\(.*\)\(@[0-9]\+\)#\2\1#' |\
  # remove excess dots and pipes
  sed 's#\.\||##g'
}
...
entry="$(echo "$tlist" | pre_process_list | fzf_select | process_list)"
...

It will need some stylish changes, I forget about multiple digit entries. image

sorry for multiple edits... i have habbit to do ctrl+enter for new line.

RaitaroH commented 1 year ago

I will have to test this for things such as:

As per your last comment, it fails decimal scores, ? number of last episodes too: image I will look into this

RaitaroH commented 1 year ago

I have a much better idea. The process_list function I wrote is already good enough, and prints output like so:

Blue Lock|12|24|5.5|
Flying Witch|0|12|0|
Isekai Oji-san|12|13|6.5|
Love Live! School idol project|5|13|0|
Mairimashita! Iruma-kun 3|12|21|5|
Meitantei Conan|1067|?|7.5|
Musekinin Kanchou Tylor|12|26|7.5|

As such I can do something like this (keep color) with awk:

$ cat /tmp/trackma | perl -pe 's/^.+?[^\s]\s+(.+?(?=\.\.))\.+\ +(\d+).[^\d]\ (\d+|\?)\s+(\d*[.]?\d+).+$/\1|\2|\3|\4|/g' | awk -F'|' '{print "@" NR-1 " - " $2" / "$3 " - " $4 " -  " $1}'
@0 - 12 / 24 - 5.5 -  Blue Lock
@1 - 0 / 12 - 0 -  Flying Witch
@2 - 12 / 13 - 6.5 -  Isekai Oji-san
@3 - 5 / 13 - 0 -  Love Live! School idol project
@4 - 12 / 21 - 5 -  Mairimashita! Iruma-kun 3
@5 - 1067 / ? - 7.5 -  Meitantei Conan
@6 - 12 / 26 - 7.5 -  Musekinin Kanchou Tylor

I just need to use printf align with awk

RaitaroH commented 1 year ago

Consider the following:

trackma -a 1 list | head -n -2 | tail -n +2 >> /tmp/trackma

Then:

cat /tmp/trackma | perl -pe 's/^.+?[^\s]\s+(.+?(?=\.\.))\.+\ +(\d+).[^\d]\ (\d+|\?)\s+(\d*[.]?\d+).+$/\1|\2|\3|\4|/g' | awk -F'|' '{printf "@%s",NR-1} {printf "%8s - %-5s",$2,$3} {printf " %-6s %s\n",$4,$1}'
Darukutsu commented 1 year ago

Consider the following:

trackma -a 1 list | head -n -2 | tail -n +2 >> /tmp/trackma

Then:

cat /tmp/trackma | perl -pe 's/^.+?[^\s]\s+(.+?(?=\.\.))\.+\ +(\d+).[^\d]\ (\d+|\?)\s+(\d*[.]?\d+).+$/\1|\2|\3|\4|/g' | awk -F'|' '{printf "@%s",NR-1} {printf "%8s - %-5s",$2,$3} {printf " %-6s %s\n",$4,$1}'

Your perl is broking some of the entries, my tmp/trackma:

trackma output | 1 3D Kanojo: Real Girl........................... 12 / 12 5 | | 2 5-toubun no Hanayome........................... 12 / 12 6 | | 3 91 Days........................................ 12 / 12 7 | | 4 Akatsuki no Yona............................... 24 / 24 7 | | 5 Akira.......................................... 1 / 1 8 | | 6 Amagami SS..................................... 25 / 25 6 | | 7 Amagami SS OVA................................. 6 / 6 5 | | 8 Amagami SS+ Plus............................... 13 / 13 6 | | 9 Ao Haru Ride................................... 12 / 12 9 | | 10 Ao Haru Ride OVA............................... 2 / 2 9 | | 11 Araburu Kisetsu no Otome-domo yo............... 12 / 12 7 | | 12 Bakemonogatari................................. 15 / 15 6 | | 13 Banana Fish.................................... 24 / 24 9 | | 14 Boku dake ga Inai Machi........................ 12 / 12 9 | | 15 Boku wa Tomodachi ga Sukunai................... 12 / 12 5 | | 16 Boku wa Tomodachi ga Sukunai Next.............. 12 / 12 5 | | 17 Bubble......................................... 1 / 1 6 | | 18 Chainsaw Man................................... 12 / 12 10 | | 19 Chou Robot Seimeitai Transformers Micron Denset 52 / 52 0 | | 20 Chuunibyou demo Koi ga Shitai! Movie: Take On M 1 / 1 6 | | 21 Citrus......................................... 12 / 12 6 | | 22 Clannad........................................ 23 / 23 7 | | 23 Clannad: After Story........................... 24 / 24 7 | | 24 Clannad: Mou Hitotsu no Sekai, Tomoyo-hen...... 1 / 1 6 | | 25 Code Geass: Boukoku no Akito 1 - Yokuryuu wa Ma 1 / 1 8 | | 26 Code Geass: Boukoku no Akito 2 - Hikisakareshi 1 / 1 8 | | 27 Code Geass: Boukoku no Akito 3 - Kagayaku Mono 1 / 1 8 | | 28 Code Geass: Boukoku no Akito 4 - Nikushimi no K 1 / 1 8 | | 29 Code Geass: Boukoku no Akito 5 - Itoshiki Mono- 1 / 1 8 | | 30 Code Geass: Fukkatsu no Lelouch................ 1 / 1 8 | | 31 Code Geass: Hangyaku no Lelouch................ 25 / 25 8 | | 32 Code Geass: Hangyaku no Lelouch I - Koudou..... 1 / 1 0 | | 33 Code Geass: Hangyaku no Lelouch II - Handou.... 1 / 1 0 | | 34 Code Geass: Hangyaku no Lelouch III - Oudou.... 1 / 1 0 | | 35 Code Geass: Hangyaku no Lelouch R2............. 25 / 25 9 | | 36 Cowboy Bebop................................... 26 / 26 7 | | 37 Darling in the FranXX.......................... 24 / 24 7 | | 38 Death Note..................................... 37 / 37 9 | | 39 Death Parade................................... 12 / 12 8 | | 40 Domestic na Kanojo............................. 12 / 12 8 | | 41 Dorohedoro..................................... 12 / 12 8 | | 42 Dororo......................................... 24 / 24 9 | | 43 Eoneu Nal Jameseo Kkaeeoboni Bagelyeoga Doeeo I 15 / 15 9 | | 44 Fuufu Ijou, Koibito Miman...................... 12 / 12 7 | | 45 Fuuka.......................................... 12 / 12 6 | | 46 Getsuyoubi no Tawawa........................... 12 / 12 5 | | 47 Gokushufudou................................... 5 / 5 7 | | 48 Golden Boy..................................... 6 / 6 10 | | 49 Golden Time.................................... 24 / 24 8 | | 50 Grand Blue..................................... 12 / 12 7 | | 51 Great Pretender................................ 23 / 23 8 | | 52 Great Teacher Onizuka.......................... 43 / 43 8 | | 53 Hajimete no Gal................................ 10 / 10 6 | | 54 Hello World.................................... 1 / 1 7 | | 55 Hige wo Soru. Soshite Joshikousei wo Hirou..... 13 / 13 6 | | 56 High School DxD................................ 12 / 12 7 | | 57 High School DxD BorN........................... 12 / 12 6 | | 58 High School DxD New............................ 12 / 12 6 | | 59 High School DxD OVA............................ 2 / 2 6 | | 60 Hinamatsuri (TV)............................... 12 / 12 6 | | 61 Horimiya....................................... 13 / 13 7 | | 62 Hotaru no Haka................................. 1 / 1 9 | | 63 Hotarubi no Mori e............................. 1 / 1 6 | | 64 Howl no Ugoku Shiro............................ 1 / 1 10 | | 65 Hyouka......................................... 22 / 22 8 | | 66 IS: Infinite Stratos........................... 12 / 12 4 | | 67 Ijiranaide, Nagatoro-san....................... 12 / 12 7 | | 68 Ishuzoku Reviewers............................. 12 / 12 8 | | 69 Isshuukan Friends.............................. 12 / 12 5 | | 70 Jaku-Chara Tomozaki-kun........................ 12 / 12 6 | | 71 Josee to Tora to Sakana-tachi.................. 1 / 1 8 | | 72 Jujutsu Kaisen................................. 24 / 24 9 | | 73 Jujutsu Kaisen 0 Movie......................... 1 / 1 8 | | 74 Kaguya-sama wa Kokurasetai: Tensai-tachi no Ren 12 / 12 6 | | 75 Kaifuku Jutsushi no Yarinaoshi................. 12 / 12 6 | | 76 Kami no Tou.................................... 13 / 13 7 | | 77 Kanojo, Okarishimasu........................... 12 / 12 8 | | 78 Kanojo, Okarishimasu 2nd Season................ 12 / 12 6 | | 79 Kaze Tachinu................................... 1 / 1 8 | | 80 Kimetsu no Yaiba............................... 26 / 26 8 | | 81 Kimetsu no Yaiba Movie: Mugen Ressha-hen....... 1 / 1 7 | | 82 Kimi no Na wa.................................. 1 / 1 8 | | 83 Kimi no Suizou wo Tabetai...................... 1 / 1 9 | | 84 Kodai Ouja Kyouryuu King....................... 49 / 49 0 | | 85 Koe no Katachi................................. 1 / 1 9 | | 86 Koi to Uso..................................... 12 / 12 5 | | 87 Kokoro Connect................................. 13 / 13 7 | | 88 Kokoro ga Sakebitagatterunda................... 1 / 1 8 | | 89 Kotonoha no Niwa............................... 1 / 1 6 | | 90 Koukaku Kidoutai............................... 1 / 1 8 | | 91 Koukaku Kidoutai: Stand Alone Complex.......... 26 / 26 9 | | 92 Koukaku Kidoutai: Stand Alone Complex 2nd GIG.. 26 / 26 7 | | 93 Kumo no Mukou, Yakusoku no Basho............... 1 / 1 6 | | 94 Kuzu no Honkai................................. 12 / 12 9 | | 95 Kyokou Suiri................................... 12 / 12 5 | | 96 Mamahaha no Tsurego ga Motokano datta.......... 12 / 12 5 | | 97 Masamune-kun no Revenge........................ 12 / 12 6 | | 98 Mashiro-iro Symphony: The Color of Lovers...... 12 / 12 7 | | 99 Metal Fight Beyblade........................... 51 / 51 0 | | 100 Metal Fight Beyblade 4D........................ 52 / 52 0 | | 101 Mieruko-chan................................... 12 / 12 7 | | 102 Mimi wo Sumaseba............................... 1 / 1 7 | | 103 Mononoke Hime.................................. 1 / 1 9 | | 104 Mushoku Tensei: Isekai Ittara Honki Dasu....... 11 / 11 8 | | 105 Nanatsu no Taizai.............................. 24 / 24 7 | | 106 Nande Koko ni Sensei ga!?...................... 12 / 12 4 | | 107 Nande Koko ni Sensei ga!? Nande Koko ni Sensei- 1 / 1 4 | | 108 Nazo no Kanojo X............................... 13 / 13 6 | | 109 Neko no Ongaeshi............................... 1 / 1 7 | | 110 Neon Genesis Evangelion........................ 26 / 26 6 | | 111 Neon Genesis Evangelion: The End of Evangelion. 1 / 1 6 | | 112 Nijiiro Days................................... 24 / 24 6 | | 113 Noragami....................................... 12 / 12 8 | | 114 Noragami Aragoto............................... 13 / 13 8 | | 115 Ookami Shoujo to Kuro Ouji..................... 12 / 12 6 | | 116 Ookami Shoujo to Kuro Ouji Recap............... 1 / 1 6 | | 117 Ookami Shoujo to Kuro Ouji: Gishinanki – Happen 1 / 1 6 | | 118 Ookami to Koushinryou.......................... 13 / 13 8 | | 119 Orange......................................... 13 / 13 6 | | 120 Perfect Blue................................... 1 / 1 6 | | 121 Psycho-Pass.................................... 22 / 22 9 | | 122 ReLIFE......................................... 13 / 13 7 | | 123 Saenai Heroine no Sodatekata................... 12 / 12 5 | | 124 Sakamoto desu ga?.............................. 12 / 12 7 | | 125 Sakamoto desu ga? Sakamoto deshita?............ 1 / 1 6 | | 126 Sakasama no Patema............................. 1 / 1 7 | | 127 Sakasama no Patema: Beginning of the Day....... 4 / 4 0 | | 128 Sakura-sou no Pet na Kanojo.................... 24 / 24 6 | | 129 Samurai Champloo............................... 26 / 26 7 | | 130 Seishun Buta Yarou wa Bunny Girl Senpai no Yume 13 / 13 8 | | 131 Sen to Chihiro no Kamikakushi.................. 1 / 1 9 | | 132 Senpai ga Uzai Kouhai no Hanashi............... 12 / 12 6 | | 133 Shigatsu wa Kimi no Uso........................ 22 / 22 7 | | 134 Shimoneta to Iu Gainen ga Sonzai Shinai Taikuts 12 / 12 6 | | 135 Shingeki no Kyojin............................. 25 / 25 8 | | 136 Shingeki no Kyojin Season 2.................... 12 / 12 7 | | 137 Shingeki no Kyojin Season 3.................... 12 / 12 8 | | 138 Sonny Boy...................................... 12 / 12 6 | | 139 Sono Bisque Doll wa Koi wo Suru................ 12 / 12 8 | | 140 Spy x Family................................... 12 / 12 8 | | 141 Spy x Family Part 2............................ 13 / 13 8 | | 142 Steins;Gate.................................... 24 / 24 10 | | 143 Steins;Gate 0.................................. 23 / 23 10 | | 144 Steins;Gate: Kyoukaimenjou no Missing Link - Di 1 / 1 0 | | 145 Stranger: Mukou Hadan.......................... 1 / 1 7 | | 146 Suki tte Ii na yo.............................. 13 / 13 8 | | 147 Summertime Render.............................. 25 / 25 9 | | 148 Tenki no Ko.................................... 1 / 1 10 | | 149 Tenkuu no Shiro Laputa......................... 1 / 1 8 | | 150 Toki wo Kakeru Shoujo.......................... 1 / 1 7 | | 151 Tokyo Revengers................................ 24 / 24 7 | | 152 Tonikaku Kawaii................................ 12 / 12 4 | | 153 Toradora!...................................... 25 / 25 8 | | 154 Trinity Seven.................................. 12 / 12 4 | | 155 Tsuki ga Kirei................................. 12 / 12 8 | | 156 Uchiage Hanabi................................. 1 / 1 8 | | 157 Umibe no Étranger.............................. 1 / 1 0 | | 158 Violet Evergarden.............................. 13 / 13 8 | | 159 Wotaku ni Koi wa Muzukashii.................... 11 / 11 5 | | 160 Yahari Ore no Seishun Love Comedy wa Machigatte 13 / 13 7 | | 161 Yakusoku no Neverland.......................... 12 / 12 7 | | 162 Yesterday wo Utatte............................ 12 / 12 8 | | 163 Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e 12 / 12 7 | | 164 Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e 13 / 13 7 | | 165 Yu☆Gi☆Oh!: Hikari no Pyramid................... 1 / 1 0 | | 166 Zutto Mae kara Suki deshita. Kokuhaku Jikkou Ii 1 / 1 6 |
perl output: 3D Kanojo: Real Girl|12|12|5| 5-toubun no Hanayome|12|12|6| 91 Days|12|12|7| Akatsuki no Yona|24|24|7| Akira|1|1|8| Amagami SS|25|25|6| Amagami SS OVA|6|6|5| Amagami SS+ Plus|13|13|6| Ao Haru Ride|12|12|9| Ao Haru Ride OVA|2|2|9| Araburu Kisetsu no Otome-domo yo|12|12|7| Bakemonogatari|15|15|6| Banana Fish|24|24|9| Boku dake ga Inai Machi|12|12|9| Boku wa Tomodachi ga Sukunai|12|12|5| Boku wa Tomodachi ga Sukunai Next|12|12|5| Bubble|1|1|6| Chainsaw Man|12|12|10| | 19 Chou Robot Seimeitai Transformers Micron Denset 52 / 52 0 | | 20 Chuunibyou demo Koi ga Shitai! Movie: Take On M 1 / 1 6 | Citrus|12|12|6| Clannad|23|23|7| Clannad: After Story|24|24|7| Clannad: Mou Hitotsu no Sekai, Tomoyo-hen|1|1|6| | 25 Code Geass: Boukoku no Akito 1 - Yokuryuu wa Ma 1 / 1 8 | | 26 Code Geass: Boukoku no Akito 2 - Hikisakareshi 1 / 1 8 | | 27 Code Geass: Boukoku no Akito 3 - Kagayaku Mono 1 / 1 8 | | 28 Code Geass: Boukoku no Akito 4 - Nikushimi no K 1 / 1 8 | | 29 Code Geass: Boukoku no Akito 5 - Itoshiki Mono- 1 / 1 8 | Code Geass: Fukkatsu no Lelouch|1|1|8| Code Geass: Hangyaku no Lelouch|25|25|8| Code Geass: Hangyaku no Lelouch I - Koudou|1|1|0| Code Geass: Hangyaku no Lelouch II - Handou|1|1|0| Code Geass: Hangyaku no Lelouch III - Oudou|1|1|0| Code Geass: Hangyaku no Lelouch R2|25|25|9| Cowboy Bebop|26|26|7| Darling in the FranXX|24|24|7| Death Note|37|37|9| Death Parade|12|12|8| Domestic na Kanojo|12|12|8| Dorohedoro|12|12|8| Dororo|24|24|9| | 43 Eoneu Nal Jameseo Kkaeeoboni Bagelyeoga Doeeo I 15 / 15 9 | Fuufu Ijou, Koibito Miman|12|12|7| Fuuka|12|12|6| Getsuyoubi no Tawawa|12|12|5| Gokushufudou|5|5|7| Golden Boy|6|6|10| Golden Time|24|24|8| Grand Blue|12|12|7| Great Pretender|23|23|8| Great Teacher Onizuka|43|43|8| Hajimete no Gal|10|10|6| Hello World|1|1|7| Hige wo Soru. Soshite Joshikousei wo Hirou|13|13|6| High School DxD|12|12|7| High School DxD BorN|12|12|6| High School DxD New|12|12|6| High School DxD OVA|2|2|6| Hinamatsuri (TV)|12|12|6| Horimiya|13|13|7| Hotaru no Haka|1|1|9| Hotarubi no Mori e|1|1|6| Howl no Ugoku Shiro|1|1|10| Hyouka|22|22|8| IS: Infinite Stratos|12|12|4| Ijiranaide, Nagatoro-san|12|12|7| Ishuzoku Reviewers|12|12|8| Isshuukan Friends|12|12|5| Jaku-Chara Tomozaki-kun|12|12|6| Josee to Tora to Sakana-tachi|1|1|8| Jujutsu Kaisen|24|24|9| Jujutsu Kaisen 0 Movie|1|1|8| | 74 Kaguya-sama wa Kokurasetai: Tensai-tachi no Ren 12 / 12 6 | Kaifuku Jutsushi no Yarinaoshi|12|12|6| Kami no Tou|13|13|7| Kanojo, Okarishimasu|12|12|8| Kanojo, Okarishimasu 2nd Season|12|12|6| Kaze Tachinu|1|1|8| Kimetsu no Yaiba|26|26|8| Kimetsu no Yaiba Movie: Mugen Ressha-hen|1|1|7| Kimi no Na wa|1|1|8| Kimi no Suizou wo Tabetai|1|1|9| Kodai Ouja Kyouryuu King|49|49|0| Koe no Katachi|1|1|9| Koi to Uso|12|12|5| Kokoro Connect|13|13|7| Kokoro ga Sakebitagatterunda|1|1|8| Kotonoha no Niwa|1|1|6| Koukaku Kidoutai|1|1|8| Koukaku Kidoutai: Stand Alone Complex|26|26|9| Koukaku Kidoutai: Stand Alone Complex 2nd GIG|26|26|7| Kumo no Mukou, Yakusoku no Basho|1|1|6| Kuzu no Honkai|12|12|9| Kyokou Suiri|12|12|5| Mamahaha no Tsurego ga Motokano datta|12|12|5| Masamune-kun no Revenge|12|12|6| Mashiro-iro Symphony: The Color of Lovers|12|12|7| Metal Fight Beyblade|51|51|0| Metal Fight Beyblade 4D|52|52|0| Mieruko-chan|12|12|7| Mimi wo Sumaseba|1|1|7| Mononoke Hime|1|1|9| Mushoku Tensei: Isekai Ittara Honki Dasu|11|11|8| Nanatsu no Taizai|24|24|7| Nande Koko ni Sensei ga!?|12|12|4| | 107 Nande Koko ni Sensei ga!? Nande Koko ni Sensei- 1 / 1 4 | Nazo no Kanojo X|13|13|6| Neko no Ongaeshi|1|1|7| Neon Genesis Evangelion|26|26|6| | 111 Neon Genesis Evangelion: The End of Evangelion. 1 / 1 6 | Nijiiro Days|24|24|6| Noragami|12|12|8| Noragami Aragoto|13|13|8| Ookami Shoujo to Kuro Ouji|12|12|6| Ookami Shoujo to Kuro Ouji Recap|1|1|6| | 117 Ookami Shoujo to Kuro Ouji: Gishinanki – Happen 1 / 1 6 | Ookami to Koushinryou|13|13|8| Orange|13|13|6| Perfect Blue|1|1|6| Psycho-Pass|22|22|9| ReLIFE|13|13|7| Saenai Heroine no Sodatekata|12|12|5| Sakamoto desu ga?|12|12|7| Sakamoto desu ga? Sakamoto deshita?|1|1|6| Sakasama no Patema|1|1|7| Sakasama no Patema: Beginning of the Day|4|4|0| Sakura-sou no Pet na Kanojo|24|24|6| Samurai Champloo|26|26|7| | 130 Seishun Buta Yarou wa Bunny Girl Senpai no Yume 13 / 13 8 | Sen to Chihiro no Kamikakushi|1|1|9| Senpai ga Uzai Kouhai no Hanashi|12|12|6| Shigatsu wa Kimi no Uso|22|22|7| | 134 Shimoneta to Iu Gainen ga Sonzai Shinai Taikuts 12 / 12 6 | Shingeki no Kyojin|25|25|8| Shingeki no Kyojin Season 2|12|12|7| Shingeki no Kyojin Season 3|12|12|8| Sonny Boy|12|12|6| Sono Bisque Doll wa Koi wo Suru|12|12|8| Spy x Family|12|12|8| Spy x Family Part 2|13|13|8| Steins;Gate|24|24|10| Steins;Gate 0|23|23|10| | 144 Steins;Gate: Kyoukaimenjou no Missing Link - Di 1 / 1 0 | Stranger: Mukou Hadan|1|1|7| Suki tte Ii na yo|13|13|8| Summertime Render|25|25|9| Tenki no Ko|1|1|10| Tenkuu no Shiro Laputa|1|1|8| Toki wo Kakeru Shoujo|1|1|7| Tokyo Revengers|24|24|7| Tonikaku Kawaii|12|12|4| Toradora!|25|25|8| Trinity Seven|12|12|4| Tsuki ga Kirei|12|12|8| Uchiage Hanabi|1|1|8| Umibe no Étranger|1|1|0| Violet Evergarden|13|13|8| Wotaku ni Koi wa Muzukashii|11|11|5| | 160 Yahari Ore no Seishun Love Comedy wa Machigatte 13 / 13 7 | Yakusoku no Neverland|12|12|7| Yesterday wo Utatte|12|12|8| | 163 Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e 12 / 12 7 | | 164 Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e 13 / 13 7 | Yu☆Gi☆Oh!: Hikari no Pyramid|1|1|0| | 166 Zutto Mae kara Suki deshita. Kokuhaku Jikkou Ii 1 / 1 6 |
RaitaroH commented 1 year ago

Ah yes, that isn't my perl regex, but instead the trackma output getting cutoff. I am working right now on a different branch you can test.

Darukutsu commented 1 year ago
echo -e "filter completed\nlist\nexit" | COLUMNS=250 trackma | sed -n '/[[:space:]].1/,${p;/results/q}' | head -n -1 >> /tmp/trackma && cat /tmp/trackma | perl -pe 's/^.+?[^\s]\s+(.+?(?=\.\.))\.+\ +(\d+).[^\d]\ (\d+|\?)\s+(\d*[.]?\d+).+$/\1|\2|\3|\4|/g' | awk -F'|' '{printf "@%s",NR} {printf "%8s - %-5s",$2,$3} {printf " %-6s %s\n",$4,$1}'

Try using COLUMNS. Why indexing from 0 when can from 1?

RaitaroH commented 1 year ago

Yeah the NR-1 was just a copy paste. Don't worry I have fixed it. And yeah, the COLUMNS has to be increased.

RaitaroH commented 1 year ago

@Darukutsu test this new branch. I have played around with awk with BEGIN {printf "%s %6s %9s %6s\n", "Index", "Count", "Score", "Title"} but I think that fzf prompt actually looks better.

Does work on pretty small size, but you know, the choices and animdl outputs can be an issue: image

RaitaroH commented 1 year ago

As my code needs the |||| format I decided to just do this:

process_list()    {
  perl -pe "s/\x1b\[[0-9;]*m//g ; s/${regex}/g"
}
fzf_process_list() {
  perl -pe "s/${regex}/g" |\
    awk -F'|' '{printf "%-2s",NR} {printf "%6s - %-5s",$2,$3} {printf " %-6s %s\n",$4,$1}'
  # print columns in the format INDEX CURRENT - LAST SCORE TITLE with proper padding
}
get_entry() {
  debug_print "get_entry()"
  fzf_selection="$(echo "$tlist" | fzf_process_list | fzf_select )"
  # now get the line number from selection
  line_nr=$(echo "$fzf_selection" | awk '{print $1}')
  # find the entry from tlist that has that number so we have the expected |||| format
  entry="$(echo "$tlist" | sed -n "$line_nr p" | process_list)"
  present=""
  debug_print_vars "fzf_selection" "line_nr" "entry"
}

Basically after you pick something, I am going through trackma output again (tlist) find the corresponding index line and process it as before.

Darukutsu commented 1 year ago

adl -c now don't display pictures. After pressing ESC first episode is selected + there is no option to switch list now (apart from adl -q query).

RaitaroH commented 1 year ago

I fixed the ESC thing.

RaitaroH commented 1 year ago

For adl -c I forgot to modify this regex: https://github.com/RaitaroH/adl/blob/d94ed157e0e41508f3c7bc05a639ce24dc159df4/adl#L251

Considering a format like so it has to print just the titles

1083    1067 - 2000  10.5   Meitantei Conan
1084      12 - 26    7.5    Musekinin Kanchou Tylor
RaitaroH commented 1 year ago

I have fixed the issues. I think adl -c should be fine now. I cannot properly test as I don't have ueberzug installed on this machine. I will keep that branch unmerged for now.

Darukutsu commented 1 year ago

I like your changes. Seems that everything is working.

Also, I would do instead of this https://github.com/RaitaroH/adl/blob/21417a9638c686b2b07c723bd105cd626c2fb49e/adl#L213 this

    awk -F'|' '{printf "%-4s",NR} {printf "%6s - %-5s",$2,$3} {printf " %-6s %s\n",$4,$1}'
RaitaroH commented 1 year ago

The query changing seems to have been broken from before. Fixed now.

Does the awk change look better in your opinion? Or you have another reason?

Darukutsu commented 1 year ago

Just space indentation: image

I was about to send that you forget
watch_another "$ans_loop" and then reference $1 :D but you fixed it already

RaitaroH commented 1 year ago

The script has become rather complex so even I forget some functions 😅

RaitaroH commented 1 year ago

On my end '%-2s' looks better than 4, maybe because I have scores with .5 image

(note that I have not adjusted the prompt spacing) image

RaitaroH commented 1 year ago

Anyhow, I will close this issue for now. If you find anything broken please reopen. I will keep the branch unmerged for now.

Darukutsu commented 1 year ago

On my end '%-2s' looks better than 4, maybe because I have scores with .5 image

(note that I have not adjusted the prompt spacing) image

This is not problem until 3 digit numbers appear and then indentation is off: image

RaitaroH commented 1 year ago

I will make the change.

RaitaroH commented 1 year ago

@Baitinq if you like test this new branch.