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

[BUG] panic if invidious has popular feed disable #26

Closed
LuckyTurtleDev opened this issue Feb 22, 2023 · 3 comments
Closed

[BUG] panic if invidious has popular feed disable #26

LuckyTurtleDev opened this issue Feb 22, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@LuckyTurtleDev
Copy link
Contributor

Youtube-tui does panic if invidious has popular feed disable:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/items/itemlist.rs:42:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

If I enable the popular feed at server youtube-tui does work again.
I have try to disable popular at the page,yml but this has not fix the problem.

main.yml:

mouse_support: true
invidious_instance: https://youtube.luckyturtle.dev
max_watch_history: 50
allow_unicode: true
message_bar_default: All good :)
images: Sixels
refresh_after_modifying_search_filters: true
image_index: 4
provider: YouTube
env:
  terminal-emulator: alacritty -e
  video-player: mpv
  download-path: '''~/Downloads/%(title)s-%(id)s.%(ext)s'''
  youtube-downloader: yt-dlp
  browser: firefox

pages.yml:

main_menu:
  layout:
  - type: NonCenteredRow
    items:
    - SearchBar
    - SearchFilters
  - type: CenteredRow
    items:
   # - Popular
    - Trending
    - History
  - type: NonCenteredRow
    items:
    - ItemList
  - type: NonCenteredRow
    items:
    - MessageBar
  message: Loading main menu...
search:
  layout:
  - type: NonCenteredRow
    items:
    - SearchBar
    - SearchFilters
  - type: NonCenteredRow
    items:
    - ItemList
  - type: NonCenteredRow
    items:
    - MessageBar
  message: Loading search results...
singleitem:
  layout:
  - type: NonCenteredRow
    items:
    - SearchBar
    - SearchFilters
  - type: NonCenteredRow
    items:
    - SingleItemInfo
  - type: NonCenteredRow
    items:
    - MessageBar
  message: Loading item details...
channeldisplay:
  layout:
  - type: NonCenteredRow
    items:
    - SearchBar
    - SearchFilters
  - type: CenteredRow
    items:
    - ChannelMain
    - ChannelVideos
    - ChannelPlaylists
  - type: NonCenteredRow
    items:
    - ChannelDisplay
  - type: NonCenteredRow
    items:
    - MessageBar
  message: Loading channel details...
@Siriusmart
Copy link
Owner

Fix

In commands.yml, change launch_command to something else (for example loadpage watchhistory ;; flush ;; history clear).

What happened

I believe when you disable the popular feed, instead of returning nothing on the api request, it returns an empty array (instead of an error) which itemlist sorta freaks out.

The Popular item in pages.yml is just the popular page button, by all it does is load a page (similar to a hyperlink). But because in the launch command in commands.yml loads the popular page on start, as soon as the page loads it crashes because it was not expected to recieve an empty array.

I'm gonna catch this case so it doesnt crash maybe later

@Siriusmart Siriusmart added the bug Something isn't working label Feb 23, 2023
@LuckyTurtleDev
Copy link
Contributor Author

LuckyTurtleDev commented Feb 25, 2023

Invidious returns a different json with status 500 if popular is disable.
https://youtube.luckyturtle.dev/api/v1/popular

{"error":"Closed stream"}

It would possible a good idea to check the status code with the .error_for_status() function.

@Siriusmart
Copy link
Owner

Apparently it was already fixed a few git commits ago, its just that the latest crates.io version (0.6.2) is not new enough to include this fix, but it will be included in the next crates.io version

this is the current behavior:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants