coderholic / pyradio

Curses based internet radio player
www.coderholic.com/pyradio
MIT License
959 stars 129 forks source link

[BUG] pyradio does not support declare custom headers #242

Closed leleobhz closed 4 months ago

leleobhz commented 5 months ago

Describe the bug Some radios does not allow being played without a Referer or other headers on request. pyradio must support some way to declare it at stations.csv

To Reproduce Steps to reproduce the behavior:

  1. Try BR|SP|SP|Cultura Brasil,https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 at stations.csv
  2. Try play this radio
  3. See error

Expected behavior This radio get played.

System (please complete the following information):

Additional context cURL reports about radio station on issue:


❯ curl -LI -H 'Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html' 'https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8'
HTTP/1.1 200 OK
Date: Wed, 22 May 2024 18:50:45 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 635
Connection: keep-alive
Server: openresty
Last-Modified: Wed, 22 May 2024 18:50:43 GMT
ETag: "664e3e83-27b"
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
X-CCDN-Origin-Time: 7
via: LA-BRA-saopaulo-EDGE8-CACHE5[14],LA-BRA-saopaulo-EDGE8-CACHE5[12,TCP_MISS,13],LA-BRA-saopaulo-GLOBAL1-CACHE9[10],LA-BRA-saopaulo-GLOBAL1-CACHE10[7,TCP_MISS,9]
x-hcs-proxy-type: 0
X-CCDN-CacheTTL: 1
X-CCDN-REQ-ID-46B1: 56221abd2805cee3fab3a83b1fc0e2e6
Accept-Ranges: bytes

~
❯ curl -LI 'https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8'
HTTP/1.1 403 Forbidden
Server: openresty
Date: Wed, 22 May 2024 18:50:56 GMT
Content-Type: text/html
Connection: keep-alive
X-CCDN-REQ-ID-46B1: d30d8c89200f6d090627ba6ea5656500
Content-Length: 350
via: LA-BRA-saopaulo-EDGE8-CACHE10[2]
X-CCDN-FORBID-CODE: 020200

~
❯ curl -L -H 'Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html' 'https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8'
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:52236
#EXT-X-TARGETDURATION:2
#EXT-X-PROGRAM-DATE-TIME:2024-05-23T02:51:12.002+08:00
#EXTINF:2.000,
culturaam_1716403872002_3640727306_52236.ts?ps=9&app=live&stream=culturaam&vhost=player-culturaam.stream.uol.com.br
#EXT-X-PROGRAM-DATE-TIME:2024-05-23T02:51:14.008+08:00
#EXTINF:2.000,
culturaam_1716403874008_3640727306_52237.ts?ps=9&app=live&stream=culturaam&vhost=player-culturaam.stream.uol.com.br
#EXT-X-PROGRAM-DATE-TIME:2024-05-23T02:51:16.004+08:00
#EXTINF:2.000,
culturaam_1716403876004_3640727306_52238.ts?ps=9&app=live&stream=culturaam&vhost=player-culturaam.stream.uol.com.br
'''
s-n-g commented 5 months ago

Hi @leleobhz

There is a way to pass a header to mpv, I haven't checked about the other players, though...

Using this command:

mpv  --no-video --http-header-fields="Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 

This is what I get

     Video --vid=1 (h264 1280x720 29.970fps)
 (+) Audio --aid=1 (aac 2ch 48000Hz)
AO: [pipewire] 48000Hz stereo 2ch floatp
Audio device underrun detected.
[ffmpeg/demuxer] hls: skipping 16 segments ahead, expired from playlists
[ffmpeg/demuxer] hls: skipping 3 segments ahead, expired from playlists
Audio device underrun detected.
Invalid audio PTS: 3.989333 -> 36.032000
Audio device underrun detected.
[ffmpeg/demuxer] hls: skipping 13 segments ahead, expired from playlists
Invalid audio PTS: 38.037333 -> 44.032000
Audio device underrun detected.
Invalid audio PTS: 46.037333 -> 72.064000
[ffmpeg/demuxer] hls: skipping 1 segments ahead, expired from playlists
Audio device underrun detected.
Audio device underrun detected.
[ffmpeg/demuxer] hls: skipping 12 segments ahead, expired from playlists
Invalid audio PTS: 76.074667 -> 78.080000
Audio device underrun detected.
[ffmpeg/demuxer] hls: skipping 2 segments ahead, expired from playlists
[ffmpeg/demuxer] hls: skipping 2 segments ahead, expired from playlists
Invalid audio PTS: 80.064000 -> 104.085333
Audio device underrun detected.
Invalid audio PTS: 106.090667 -> 110.101333
Audio device underrun detected.
(Buffering) A: 00:01:50 / 00:01:50 (100%) Cache: 0.0s
Exiting... (Quit)

First of all, it takes it too long to start the actual playback, if you can call it that... I only get chopped sound out of it...

Every Audio device underrun detected. means the sound stops, then it seems to start buffering, play a second of sound and keeps buffering again...

Of course, I am halfway across the world...

Does that command even work for you?

leleobhz commented 4 months ago

Hello @s-n-g !

I got a curious result here. I've configured following way at stations.csv

077.9 MHz - Cultura Brasil,--http-header-fields="Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/l
ive/culturaam.m3u8,-

Playing at pyradio result this:

image

But while I command pyradio to play this radio, i ran this bashism:

leonardo@miriam:~$ while true; do ps aux | grep mpv | grep cultura |grep -v grep ; done
leonardo   32960  100  0.0 381628 16160 pts/3    R+   08:43   0:00 mpv --no-video --quiet --http-header-fields="Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 --input-ipc-server=/tmp/mpvsocket.29298 --profile=pyradio
leonardo   32960  100  0.1 382448 46040 pts/3    R+   08:43   0:00 mpv --no-video --quiet --http-header-fields="Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 --input-ipc-server=/tmp/mpvsocket.29298 --profile=pyradio

And if I run exactly this command on cli:

image

Add commands to pyradio url is suposed to work but does not. pyradio is a code I don't read it too much (I just found this project this week!), but I guess someway to allow extra params to player commandline may be desirable on stations.csv.

What do you think about it?

s-n-g commented 4 months ago

ok, I think I got it working...

I just needed to add the User-Agent

I would like you to test it though, because I cannot play the video (not with mpv, not with pyradio, and not in firefox)

To do that, you have to find the file called player.py in pyradio installation

An easy way to do that is to execute pyradio, press "\o" and press ENTER on the "Code Directory" entry; this should open you file manager.

For me, the directory is: ~/.local/pipx/venvs/pyradio/lib/python3.12/site-packages/pyradio

Then save the following patch file in this directory (save it as 242.patch)

diff --git a/pyradio/player.py b/pyradio/player.py
index 678b283..8e39a19 100644
--- a/pyradio/player.py
+++ b/pyradio/player.py
@@ -2520,6 +2520,11 @@ class MpvPlayer(Player):
             else:
                 opts = [self.PLAYER_CMD, '--no-video', '--quiet', self._url_to_use(streamUrl), '--input-unix-socket=' + self.mpvsocket]

+        ##################################################################
+        if streamUrl == r'https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8' or \
+                streamUrl == r'http://player-culturaam.stream.uol.com.br/live/culturaam.m3u8':
+            opts.insert(3, r'--http-header-fields="User-Agent: PyRadio,Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html"')
+        ##################################################################
         if self._cnf.buffering_data:
             opts.extend(self._cnf.buffering_data)

Finally, apply the patch

patch -u -b player.py -i 242.patch

BTW, the playlist entry (in stations.csv") should be:

077.9 MHz - Cultura Brasil,https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8

Then try to play the video with pyradio (execute pyradio -d in a terminal) and tell me if that fixes it

This is my log file regarding this:

2024-05-26 13:50:34,813 - pyradio.player:play():2030 - INFO: Executing command: mpv --no-video --quiet --http-header-fields="User-Agent: PyRadio,Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 --input-ipc-server=/tmp/mpvsocket.10769 --profile=pyradio
2024-05-26 13:50:34,813 - pyradio.player:updateMPVStatus():1302 - DEBUG: MPV updateStatus thread started.
2024-05-26 13:50:34,814 - pyradio.player:play():2130 - DEBUG: playback detection thread started
2024-05-26 13:50:34,814 - pyradio.player:play():2141 - INFO: ----==== mpv player started ====----
2024-05-26 13:50:34,814 - pyradio.radio:_set_active_stations():4258 - ERROR: DE active_stations = 

[['077.9 MHz - Cultura Brasil', 44], ['077.9 MHz - Cultura Brasil', 44]]

2024-05-26 13:50:34,870 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"request_id":0,"error":"success"}\n'"
2024-05-26 13:50:34,870 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"property-change","id":1,"name":"metadata"}\n{"request_id":100,"error":"property unavailable"}\n{"request_id":200,"error":"property unavailable"}\n'"
2024-05-26 13:50:34,871 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"request_id":300,"error":"property unavailable"}\n{"request_id":400,"error":"property unavailable"}\n'"
2024-05-26 13:50:34,873 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"start-file","playlist_entry_id":1}\n'"
2024-05-26 13:50:37,221 - pyradio.radio:detectUpdateThread():4571 - INFO: detectUpdateThread: PyRadio is up to date. Will check again in 10 days...
2024-05-26 13:50:38,345 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
2024-05-26 13:50:38,347 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n{"event":"file-loaded"}\n'"
2024-05-26 13:50:38,348 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"property-change","id":1,"name":"metadata","data":{}}\n'"
2024-05-26 13:50:38,352 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
2024-05-26 13:50:38,352 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"playback-restart"}\n'"
2024-05-26 13:50:38,416 - pyradio.player:_set_mpv_playback_is_on():1884 - INFO: *** _set_mpv_playback_is_on(): Start of playback detected ***
2024-05-26 13:50:38,416 - pyradio.config:_show_station_history_debug():3166 - DEBUG: >>> Stations history
2024-05-26 13:50:38,417 - pyradio.config:_show_station_history_debug():3169 - DEBUG:    ['stations', '077.9 MHz - Cultura Brasil', 44]
2024-05-26 13:50:38,417 - pyradio.config:_show_station_history_debug():3170 - DEBUG:    item was = 0
2024-05-26 13:50:38,417 - pyradio.log:_write_title_to_log():613 - CRITICAL: >>> Station: 077.9 MHz - Cultura Brasil
2024-05-26 13:50:38,417 - pyradio.log:_show_notification():479 - DEBUG: Sending Desktop Notification: ['notify-send', '-i', '/home/spiros/.local/share/pyradio/pyradio.png', 'Station', '077.9 MHz - Cultura Brasil']
2024-05-26 13:50:38,418 - pyradio.log:_show_notification():518 - ERROR: Not starting Desktop Notification Thread!!! thread = None, enable_notifications = 0
2024-05-26 13:50:38,418 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":{},"request_id":100,"error":"success"}\n'"
2024-05-26 13:50:38,418 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":{"samplerate":48000,"channel-count":2,"channels":"stereo","hr-channels":"stereo","format":"floatp"},"request_id":200,"error":"success"}\n{"data":"AAC (Advanced Audio Coding)","request_id":300,"error":"success"}\n{"data":"aac","request_id":400,"error":"success"}\n'"
2024-05-26 13:50:38,418 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":{},"request_id":100,"error":"success"}\n{"data":{"samplerate":48000,"channel-count":2,"channels":"stereo","hr-channels":"stereo","format":"floatp"},"request_id":200,"error":"success"}\n{"data":"AAC (Advanced Audio Coding)","request_id":300,"error":"success"}\n{"data":"aac","request_id":400,"error":"success"}\n'"
2024-05-26 13:50:42,222 - pyradio.radio:detectUpdateStationsThread():4499 - DEBUG: detectUpdateStationsThread: stations.csv is up to date!!!
2024-05-26 13:52:27,027 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
s-n-g commented 4 months ago

Playing video using Referer (reference for the future)

Trying to pass referer to mpv, mplayer and vlc Also trying to pass user-agent (not a must)

mpv

The option to use is:

--http-header-fields=<string>

The command is:

mpv --v \
--http-header-fields="User-Agent: PyRadio/0.9.3.6,Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" \
https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8

mpv reports:

[cplayer] Setting option 'http-header-fields' = 'User-Agent: PyRadio/0.9.3.6,Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html' (flags = 8)

mplayer

The option to use is:

-http-header-fields <string>

The command is:

mplayer -v  \
-http-header-fields \
"Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" \
http://player-culturaam.stream.uol.com.br/live/culturaam.m3u8

The result is:

[https @ 0x7f166a27fa60]request: GET /live/culturaam.m3u8 HTTP/1.1
User-Agent: Lavf/60.16.100
Accept: */*
Range: bytes=0-
Connection: close
Host: player-culturaam.stream.uol.com.br
Icy-MetaData: 1

[https @ 0x7f166a27fa60]HTTP error 403 Forbidden
Failed to open https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8.

mplayer does not use the referer string specified

vlc

--http-referrer <string>
--http-user-agent <string>

The command is:

vlc -vv --http-user-agent "PyRadio/0.9.3.6" \
--http-referrer \
"https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" \
https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8

vlc sends:

[00007ff21c001640] http stream debug: outgoing request:
GET /live/culturaam.m3u8 HTTP/1.1
Host: player-culturaam.stream.uol.com.br
Accept: */*
Accept-Language: en_US
User-Agent: VLC/3.0.20 LibVLC/3.0.20
Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html
Range: bytes=0-

It seems only the referer is used

leleobhz commented 4 months ago

Hello @s-n-g

That said, it's possible to add to streams.csv parser a new column to declare extra players options?

s-n-g commented 4 months ago

It would be possible, yes, but you haven't answered to me... You see I would not like to make such changes before making sure it works, and I cannot test it

Have you applied the patch provided here: https://github.com/coderholic/pyradio/issues/242#issuecomment-2132181592 Did you get the station to play? Do you hear the sound ok (no interruptions, no chopping sound)?

leleobhz commented 4 months ago

Hello @s-n-g

Sorry, I've answered too fast. Yes, I applied this patch on PKGBUILD (Easier to track) and played the Radio with sucess. This is my pyradio.log file:

2024-05-31 15:11:34,392 - pyradio.config:get_pyradio_version():1830 - DEBUG: versrion = 0.9.3.7 - git_info = ['0.9.3.7', '2', 'g7f268b7']
2024-05-31 15:11:34,393 - pyradio.radio:setup():985 - INFO: <<<===---  Program start  ---===>>>
2024-05-31 15:11:34,394 - pyradio.radio:setup():989 - INFO: PyRadio 0.9.3.7-r2: TUI initialization on python v. 3.12.3 (main, Apr 27 2024, 12:27:19) [GCC 13.2.1 20230801] on Arch Linux (AUR) (Linux, miriam, 6.9.1-4-cachyos, #1 SMP PREEMPT_DYNAMIC Thu, 23 May 2024 03:58:43 +0000, x86_64, )
2024-05-31 15:11:34,396 - pyradio.radio:setup():1010 - INFO: Terminal supports 256 colors (first color to define = 15)
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():152 - DEBUG: Theme says: I work both with and without transparency (2)
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():156 - DEBUG: Config says: Transparency is OFF
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():160 - DEBUG: Config says: Do not force transparency
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():166 - DEBUG: Using config transparency setting!
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():176 - INFO: *** Active transparency is OFF
2024-05-31 15:11:34,396 - pyradio.themes:_do_init_pairs():230 - DEBUG: --> 1 transparency: OFF (use_calculated_colors: False, has_border_background: True)
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():152 - DEBUG: Theme says: I work both with and without transparency (2)
2024-05-31 15:11:34,396 - pyradio.themes:calculate_transparency():156 - DEBUG: Config says: Transparency is OFF
2024-05-31 15:11:34,397 - pyradio.themes:calculate_transparency():160 - DEBUG: Config says: Do not force transparency
2024-05-31 15:11:34,397 - pyradio.themes:calculate_transparency():166 - DEBUG: Using config transparency setting!
2024-05-31 15:11:34,397 - pyradio.themes:calculate_transparency():176 - INFO: *** Active transparency is OFF
2024-05-31 15:11:34,397 - pyradio.themes:_do_init_pairs():230 - DEBUG: --> 1 transparency: OFF (use_calculated_colors: False, has_border_background: True)
2024-05-31 15:11:34,397 - pyradio.config:get_pyradio_version():1830 - DEBUG: versrion = 0.9.3.7 - git_info = ['0.9.3.7', '2', 'g7f268b7']
2024-05-31 15:11:34,397 - pyradio.radio:setup():1044 - INFO: RyRadio built from git: https://github.com/coderholic/pyradio/commit/g7f268b7 (rev. 2)
2024-05-31 15:11:34,423 - pyradio.player:probePlayer():4174 - INFO: Probing available multimedia players...
2024-05-31 15:11:34,424 - pyradio.player:probePlayer():4177 - INFO: Implemented players: mpv, mplayer, vlc
2024-05-31 15:11:34,424 - pyradio.player:check_player():4212 - INFO: <class 'pyradio.player.MpvPlayer'> supported.
2024-05-31 15:11:34,425 - pyradio.player:check_player():4216 - DEBUG: <class 'pyradio.player.MpPlayer'> not supported.
2024-05-31 15:11:34,426 - pyradio.player:check_player():4216 - DEBUG: <class 'pyradio.player.VlcPlayer'> not supported.
2024-05-31 15:11:34,426 - pyradio.player:probePlayer():4185 - INFO: Available players: mpv
2024-05-31 15:11:34,426 - pyradio.radio:setupAndDrawScreen():1165 - DEBUG: body starts at line 2, ends at line 43
2024-05-31 15:11:34,427 - pyradio.radio:initBody():1295 - DEBUG: maxY = 40, maxX = 172
2024-05-31 15:11:34,433 - pyradio.radio:_redisplay_stations_and_playlists():9839 - DEBUG: clearing window from line 24 to end.
2024-05-31 15:11:34,434 - pyradio.radio:ll():408 - ERROR: DE ==========
2024-05-31 15:11:34,434 - pyradio.radio:ll():409 - ERROR: DE ===> setup
2024-05-31 15:11:34,434 - pyradio.radio:ll():410 - ERROR: DE NORMAL_MODE: 0, 0, -1
2024-05-31 15:11:34,434 - pyradio.radio:ll():411 - ERROR: DE PLAYLIST_MODE: 0, 0, 0
2024-05-31 15:11:34,434 - pyradio.radio:ll():412 - ERROR: DE REGISTER_MODE: 0, 0, -1
2024-05-31 15:11:34,434 - pyradio.radio:ll():414 - ERROR: DE
2024-05-31 15:11:34,434 - pyradio.radio:ll():415 - ERROR: DE p NORMAL_MODE: 0, 0, -1
2024-05-31 15:11:34,434 - pyradio.radio:ll():416 - ERROR: DE p PLAYLIST_MODE: 0, 0, 0
2024-05-31 15:11:34,435 - pyradio.radio:ll():417 - ERROR: DE p REGISTER_MODE: 0, 0, -1
2024-05-31 15:11:34,435 - pyradio.radio:_register_signals_handlers():10116 - DEBUG: SetConsoleCtrlHandler: Handler for signal SIGHUP registered
2024-05-31 15:11:34,435 - pyradio.radio:_register_signals_handlers():10116 - DEBUG: SetConsoleCtrlHandler: Handler for signal SIGTERM registered
2024-05-31 15:11:34,435 - pyradio.radio:_register_signals_handlers():10119 - DEBUG: SetConsoleCtrlHandler: Failed to register handler for signal SIGKIL
2024-05-31 15:11:34,435 - pyradio.radio:run():1911 - INFO: (detectUpdateThread): distro installation detected. Not starting!!!
2024-05-31 15:11:34,435 - pyradio.radio:run():1938 - INFO: (detectUpdateStationsThread): checking in 10 seconds
2024-05-31 15:11:36,354 - pyradio.player:play():2018 - INFO: Selected Station: 077.9 MHz - Cultura Brasil
2024-05-31 15:11:36,501 - pyradio.player:_buildStartOpts():2506 - DEBUG: --input-ipc-server is supported.
2024-05-31 15:11:36,502 - pyradio.player:_buildStartOpts():2554 - INFO: Using profile: "[pyradio]"
2024-05-31 15:11:36,502 - pyradio.player:play():2030 - INFO: Executing command: mpv --no-video --quiet --http-header-fields="User-Agent: PyRadio,Referer: https://cultura.uol.com.br/aovivo/67_ao-vivo-radio-cultura-brasil.html" https://player-culturaam.stream.uol.com.br/live/culturaam.m3u8 --input-ipc-server=/tmp/mpvsocket.424245 --profile=pyradio
2024-05-31 15:11:36,503 - pyradio.player:updateMPVStatus():1302 - DEBUG: MPV updateStatus thread started.
2024-05-31 15:11:36,504 - pyradio.player:play():2130 - DEBUG: playback detection thread started
2024-05-31 15:11:36,504 - pyradio.player:play():2141 - INFO: ----==== mpv player started ====----
2024-05-31 15:11:36,504 - pyradio.radio:_set_active_stations():4258 - ERROR: DE active_stations = 

[['077.9 MHz - Cultura Brasil', 15], ['077.9 MHz - Cultura Brasil', 15]]

2024-05-31 15:11:36,509 - pyradio.radio:_redisplay_stations_and_playlists():9839 - DEBUG: clearing window from line 24 to end.
2024-05-31 15:11:36,649 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"request_id":0,"error":"success"}\n'"
2024-05-31 15:11:36,650 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"property-change","id":1,"name":"metadata"}\n'"
2024-05-31 15:11:36,650 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"request_id":100,"error":"property unavailable"}\n{"request_id":200,"error":"property unavailable"}\n{"request_id":300,"error":"property unavailable"}\n{"request_id":400,"error":"property unavailable"}\n'"
2024-05-31 15:11:36,655 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"start-file","playlist_entry_id":1}\n'"
2024-05-31 15:11:37,406 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
2024-05-31 15:11:37,407 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n{"event":"file-loaded"}\n'"
2024-05-31 15:11:37,408 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"property-change","id":1,"name":"metadata","data":{}}\n'"
2024-05-31 15:11:37,415 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
2024-05-31 15:11:37,416 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"playback-restart"}\n'"
2024-05-31 15:11:37,465 - pyradio.player:_set_mpv_playback_is_on():1884 - INFO: *** _set_mpv_playback_is_on(): Start of playback detected ***
2024-05-31 15:11:37,465 - pyradio.config:_show_station_history_debug():3166 - DEBUG: >>> Stations history
2024-05-31 15:11:37,465 - pyradio.config:_show_station_history_debug():3169 - DEBUG:    ['stations', '077.9 MHz - Cultura Brasil', 15]
2024-05-31 15:11:37,465 - pyradio.config:_show_station_history_debug():3170 - DEBUG:    item was = 0
2024-05-31 15:11:37,466 - pyradio.log:_write_title_to_log():613 - CRITICAL: >>> Station: 077.9 MHz - Cultura Brasil
2024-05-31 15:11:37,466 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":{},"request_id":100,"error":"success"}\n'"
2024-05-31 15:11:37,466 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":{"samplerate":48000,"channel-count":2,"channels":"stereo","hr-channels":"stereo","format":"floatp"},"request_id":200,"error":"success"}\n{"data":"AAC (Advanced Audio Coding)","request_id":300,"error":"success"}\n'"
2024-05-31 15:11:37,467 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"data":"aac","request_id":400,"error":"success"}\n{"data":{},"request_id":100,"error":"success"}\n{"data":{"samplerate":48000,"channel-count":2,"channels":"stereo","hr-channels":"stereo","format":"floatp"},"request_id":200,"error":"success"}\n{"data":"AAC (Advanced Audio Coding)","request_id":300,"error":"success"}\n{"data":"aac","request_id":400,"error":"success"}\n'"
2024-05-31 15:11:40,468 - pyradio.player:updateMPVStatus():1342 - ERROR: DE Received: "b'{"event":"audio-reconfig"}\n'"
2024-05-31 15:11:40,469 - pyradio.player:updateMPVStatus():1421 - INFO: MPV updateStatus thread stopped.
2024-05-31 15:11:40,494 - pyradio.player:_kill_process_tree():2264 - DEBUG: PID 424312 (and its children)  killed...
2024-05-31 15:11:40,512 - pyradio.config:save_config():2670 - DEBUG: saved params = {'mpv': [1, 'profile:pyradio'], 'mplayer': [1, 'profile:pyradio'], 'vlc': [1, 'Do not use any extra player parameters']}
2024-05-31 15:11:40,512 - pyradio.config:save_config():2676 - INFO: Config not saved (not modified)
2024-05-31 15:11:40,640 - pyradio.radio:delay():4466 - DEBUG: detectUpdateStationsThread: Asked to stop. Stoping...
2024-05-31 15:11:40,643 - pyradio.config:remove_session_lock_file():1969 - INFO: Lock file removed...

Do you think this validates the need for a new field for custom player (I think have a referal field is too much specific to mantain) options at stations.csv?

s-n-g commented 4 months ago

Yes, this is too much, to be frank :smile:

Adding a new field in the CSV is too much IMHO...

Furthermore, it would mean that changes have to be done in:

That's too much...

I do like it that it is possible, but... I do not think a normal pyradio user will ever use this... but I will think about it and try to find a way to add it as an "extra feature" without disturbing the normal user too much

I was thinking, maybe, have the user manually create a file in ~/.config/pyradio: if the station is called "XXX_YYY", the file would by ~/.config/pyradio/XXX_YYY.headers , for example.

This file would contain the referer for the station, and pyradio would read it and add it to the command...

I am open to suggestions though

s-n-g commented 4 months ago

I have gone with a variation of the above...

You can find it here: https://github.com/s-n-g/pyradio/tree/devel

The documentation is here: https://github.com/s-n-g/pyradio/blob/devel/docs/index.md#specifying-a-stations-referer-url

I believe this would conclude this topic. Can we close the issue?

leleobhz commented 4 months ago

I have gone with a variation of the above...

You can find it here: https://github.com/s-n-g/pyradio/tree/devel

The documentation is here: https://github.com/s-n-g/pyradio/blob/devel/docs/index.md#specifying-a-stations-referer-url

I believe this would conclude this topic. Can we close the issue?

Hello @s-n-g

I've built your repo and it worked as documented (Also, since my radio name contains spaces, I confirm it works too):

image

I think you can close and merge it! Thank you so much!

s-n-g commented 4 months ago

In devel