/
/
/
1"""Tests for cleaning radio streamtitle."""
2
3from music_assistant.helpers.util import clean_stream_title
4
5
6def test_cleaning_streamtitle() -> None:
7 """Tests for cleaning radio streamtitle."""
8 tstm = "Thirty Seconds To Mars - Closer to the Edge"
9 advert = "Advert"
10
11 line = "Advertisement_Start_Length=00:00:29.960"
12 stream_title = clean_stream_title(line)
13 assert stream_title == advert
14
15 line = "Advertisement_Stop"
16 stream_title = clean_stream_title(line)
17 assert stream_title == advert
18
19 line = "START_AD_BREAK_6000"
20 stream_title = clean_stream_title(line)
21 assert stream_title == advert
22
23 line = "STOP ADBREAK 1"
24 stream_title = clean_stream_title(line)
25 assert stream_title == advert
26
27 line = "AD 2"
28 stream_title = clean_stream_title(line)
29 assert stream_title == advert
30
31 line = 'title="Thirty Seconds To Mars - Closer to the Edge",artist="Thirty Seconds To Mars - Closer to the Edge",url="https://nowplaying.scahw.com.au/c/fd8ee07bed6a5e4e9824a11aa02dd34a.jpg?t=1714568458&l=250"' # noqa: E501
32 stream_title = clean_stream_title(line)
33 assert stream_title == tstm
34
35 line = 'title="https://listenapi.planetradio.co.uk/api9.2/eventdata/247801912",url="https://listenapi.planetradio.co.uk/api9.2/eventdata/247801912"'
36 stream_title = clean_stream_title(line)
37 assert stream_title == ""
38
39 line = 'title="Thirty Seconds To Mars - Closer to the Edge https://nowplaying.scahw.com.au/",artist="Thirty Seconds To Mars - Closer to the Edge",url="https://nowplaying.scahw.com.au/c/fd8ee07bed6a5e4e9824a11aa02dd34a.jpg?t=1714568458&l=250"' # noqa: E501
40 stream_title = clean_stream_title(line)
41 assert stream_title == tstm
42
43 line = 'title="Closer to the Edge",artist="Thirty Seconds To Mars",url="https://nowplaying.scahw.com.au/c/fd8ee07bed6a5e4e9824a11aa02dd34a.jpg?t=1714568458&l=250"'
44 stream_title = clean_stream_title(line)
45 assert stream_title == tstm
46
47 line = 'title="Thirty Seconds To Mars - Closer to the Edge"'
48 stream_title = clean_stream_title(line)
49 assert stream_title == tstm
50
51 line = "Thirty Seconds To Mars - Closer to the Edge https://nowplaying.scahw.com.au/"
52 stream_title = clean_stream_title(line)
53 assert stream_title == tstm
54
55 line = "Lonely Street By: Andy Williams - WALMRadio.com"
56 stream_title = clean_stream_title(line)
57 assert stream_title == "Andy Williams - Lonely Street"
58
59 line = "Bye Bye Blackbird By: Sammy Davis Jr. - WALMRadio.com"
60 stream_title = clean_stream_title(line)
61 assert stream_title == "Sammy Davis Jr. - Bye Bye Blackbird"
62
63 line = (
64 "Asha Bhosle, Mohd Rafi (mp3yaar.com) - Gunguna Rahe Hain Bhanwre - Araadhna (mp3yaar.com)"
65 )
66 stream_title = clean_stream_title(line)
67 assert stream_title == "Asha Bhosle, Mohd Rafi - Gunguna Rahe Hain Bhanwre - Araadhna"
68
69 line = "Mohammed Rafi(Jatt.fm) - Rang Aur Noor Ki Baraat (Ghazal)(Jatt.fm)"
70 stream_title = clean_stream_title(line)
71 assert stream_title == "Mohammed Rafi - Rang Aur Noor Ki Baraat (Ghazal)"
72