XMLTV / xmltv

Utilities to obtain, generate, and post-process TV listings data in XMLTV format
GNU General Public License v2.0
266 stars 93 forks source link

uk_tvguide: automatically find alternative IDs #206

Closed mkbloke closed 1 year ago

mkbloke commented 1 year ago

What type of Pull Request is this?

Does this PR close any currently open issues?

No.

Please explain what this PR does

So, I've finally got fed up with TVG switching IDs for BBC News. It's been 66 since forever, but recently it's been hopping back and forth between 66 and 2148.

This PR aims to address the problem. Let me know what you think. If you like the idea of it, should the alternative lookup be hard-coded in as it is now or should it be possible to turn it on/off via a command line switch? Should it default to enabled or disabled in that case?

Debug log of ./tv_grab_uk_tvguide --legacychannels --days 8 --offset -4 --output tv.xml --debug &> tv.log for BBC News (66):

Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F18%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F18%2F2023%2000%3A00%3A00 from server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F19%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F19%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F20%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F20%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F21%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F21%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F22%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F22%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F23%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F23%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F24%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F24%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F25%2F2023%2000%3A00%3A00 from cache without checking with server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F25%2F2023%2000%3A00%3A00 from cache without checking with server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=66&cTime=04%2F26%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 66
Found alternative IDs: 2148
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=2148&cTime=04%2F26%2F2023%2000%3A00%3A00 from server.
...
Exiting without warnings.

Debug log of ./tv_grab_uk_tvguide --legacychannels --days 1 --offset 0 --output tv.xml --debug &> tv.log for Sky Sports Golf (1586):

Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1586&cTime=04%2F22%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 1586
Found alternative IDs: 1522 1541 1881 1883 1517 1609 1528 1607 1112 1553 1545 1534 1809 1613 1549
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1522&cTime=04%2F22%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 1522
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1541&cTime=04%2F22%2F2023%2000%3A00%3A00 from server.
...
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1586&cTime=04%2F23%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 1586
Found alternative IDs: 1522 1541 1881 1883 1517 1609 1528 1607 1112 1553 1545 1534 1809 1613 1549
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1522&cTime=04%2F23%2F2023%2000%3A00%3A00 from server.
No schedule found for channel ID: 1522
Fetching https://www.tvguide.co.uk/channellistings.asp?ch=1541&cTime=04%2F23%2F2023%2000%3A00%3A00 from server.
...
Exiting without warnings.

Where have you tested these changes?

Operating System: Linux

Perl Version: 5.24.1

honir commented 1 year ago

Sorry for the delay in replying. Nice work: I like it!

I've made a couple of performance tweaks (to cache/shortcut the array searching) - could you give them a twirl?

I can't see a use case for making this method optional (rather than mandatory). It fixes the problem for lots of people (including those who didn't even know they had a problem ;) )

mkbloke commented 1 year ago

I've given your changes a twirl and all looks good as far as I can see. I tested BBC News and Sky Sports Golf again. Good stuff!

honir commented 1 year ago

Thanks. I've committed your change, to the main repo.