JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.02k stars 2.37k forks source link

Some bug or error in YTM #639

Closed naruko-hstk closed 3 years ago

naruko-hstk commented 3 years ago

Prerequisites

Description

[Description of the bug or feature]

Environment

Steps to Reproduce

When I using YTM and api_url set http://localhost:9863 it can't show status in YouTube Music Desktop App Only I set http://my-ip:9863 can use it and need to refresh again and again.

Expected behavior: [What you expected to happen] image Actual behavior: [What actually happened]

JanDeDobbeleer commented 3 years ago

@james10949 what do you mean with need to refresh again and again? Localhost can be an issue depending on the platform/setup I suppose.

kimblesa commented 3 years ago

@JanDeDobbeleer I can confirm this is an issue for me as well, but my issue is it simply doesn't work at all -- I saw no need to refresh again and again. Following the docs, I verified that I could hit the YTM endpoint myself with postman, and got back sensible JSON output that matches the structure in the segment.

Is there a way to get some logs out to figure out why the segment choked? I saw nothing apparent in the code short of running it locally, but I figured I'd ask.

Environment

{
  "type": "ytm",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#FF0000",
  "properties": {
    "prefix": "\uF16A ",
    "playing_icon": "\uE602 ",
    "paused_icon": "\uF8E3 ",
    "stopped_icon": "\uF04D ",
    "track_separator" : " - ",
    "api_url": "http://localhost:9863"
  }
}

2021-04-12 14_24_08-Postman

sample JSON output from endpoint:

{
    "player": {
        "hasSong": true,
        "isPaused": false,
        "volumePercent": 95,
        "seekbarCurrentPosition": 4,
        "seekbarCurrentPositionHuman": "0:04",
        "statePercent": 0.011764705882352941,
        "likeStatus": "INDIFFERENT",
        "repeatType": "NONE"
    },
    "track": {
        "author": "Future Islands",
        "title": "The Fountain",
        "album": "",
        "cover": "https://lh3.googleusercontent.com/LhFwTM-OuArSvdc_Js33BlNkY6RYPMXibAkxjBm41XSrDLoKOqzhY_cfXvKITg7kKgK8k8ivTw5VD1pA=w544-h544-l90-rj",
        "duration": 340,
        "durationHuman": "5:40",
        "url": "https://www.youtube.com/watch?list=RDAMPLOLAK5uy_k_1BYTjiI3oyaTWHkp8pfeyba2U5IlFYQ&v=BCShc8d-8Js",
        "id": "BCShc8d-8Js",
        "isVideo": false,
        "isAdvertisement": false,
        "inLibrary": false
    }
}
JanDeDobbeleer commented 3 years ago

@kimblesa it's too slow. If you look at the request timing it's 512ms. We stop at 20ms because the impact is too high. This was never an issue in the past so maybe something changed at YTDM.

kimblesa commented 3 years ago

After mocking the result with my own web app, can confirm it works fine when returning sub-20ms. I ran YTDM on two different machines, and the call never got anywhere near a 20ms response time. I will consider filing an issue with YTDM, and will write a simple app to cache the result from YTDM myself for now :) thanks for the prompt response.

JanDeDobbeleer commented 3 years ago

@kimblesa for reference, this is on my machine (macOS, but also validated on Windows)

image
tenicio commented 3 years ago

I was able to workaround the issue by specifying the loopback address: "api_url": "http://127.0.0.1:9863".

So perhaps a name resolution issue?

kimblesa commented 3 years ago

@tenicio that did the trick! It does appear that some part of my networking stack adds significant amount of latency, that I was able to avoid when hitting a simple caching app I was running on localhost. Thanks so much for the feedback.

JanDeDobbeleer commented 3 years ago

I'll make sure to add the local ip by default.

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.