lzeke0 / TwitchRSS

Webapp serving RSS of Twitch broadcasts
Other
123 stars 14 forks source link

rss feed (including vodonly) also returns highlights #30

Open wyattscarpenter opened 2 years ago

wyattscarpenter commented 2 years ago

Salutations,

Today, I visited https://twitchrss.appspot.com/vodonly/j_blow to get a listing of recent videos from this twitch streamer. However, there are presently fewer than 20 videos in his current vod archives https://www.twitch.tv/j_blow/video/1267791496?filter=archives&sort=time, so it seems the rss feed filled up the rest of the list with the most recent highlights from the channel https://www.twitch.tv/j_blow/videos?filter=highlights&sort=time.

The behavior is undesirable to my ends, and probably to others' as well.

This is the current ending of the rss file, which will hopefully illustrate the problem if any doubt remains:

<item><title>Later we might program a little bit. Maybe not.</title><link>https://www.twitch.tv/videos/1582227390</link><description>&lt;a href="https://www.twitch.tv/videos/1582227390"&gt;&lt;img src="https://static-cdn.jtvnw.net/cf_vods/d1m7jfoe9zdc1j/ae4848d1c83d48e949b8_j_blow_40166760585_1662342785//thumb/thumb0-512x288.jpg" /&gt;&lt;/a&gt;</description><guid isPermaLink="false">1582227390</guid><pubDate>Mon, 05 Sep 2022 01:53:09 UT</pubDate><category>archive</category></item><item><title>Highlight: Simple Package Format</title><link>https://www.twitch.tv/videos/1267791496</link><description>&lt;a href="https://www.twitch.tv/videos/1267791496"&gt;&lt;img src="https://static-cdn.jtvnw.net/cf_vods/d1m7jfoe9zdc1j/0167237ab06415123679_j_blow_55298038665_1476158148//thumb/thumb1267791496-512x288.jpg" /&gt;&lt;/a&gt;</description><guid isPermaLink="false">1267791496</guid><pubDate>Tue, 18 Jan 2022 15:18:46 UT</pubDate><category>highlight</category></item><item><title>Highlight: Crank Session: Let's Make Bytecode Debugger!</title><link>https://www.twitch.tv/videos/895714072</link><description>&lt;a href="https://www.twitch.tv/videos/895714072"&gt;&lt;img src="https://static-cdn.jtvnw.net/cf_vods/d2nvs31859zcd8/426b3d692497b80ddcf2_j_blow_73988563302_5587585564//thumb/thumb895714072-512x288.jpg" /&gt;&lt;/a&gt;</description><guid isPermaLink="false">895714072</guid><pubDate>Sun, 31 Jan 2021 18:18:52 UT</pubDate><category>highlight</category></item></channel></rss>

Note how after the 18th and final <category>archive</category> item from the vod archive, the final two items are <category>highlight</category>.

Luckily, this is perhaps a very simple fix. https://dev.twitch.tv/docs/api/videos claims

By default, the API returns the broadcaster’s VODs, highlights, and uploads. To filter the list by type, use the type query parameter. To return only VODs, set type to archive; to return only highlights, set type to highlights; and to return only videos that the broadcaster has uploaded, set type to upload.

The following example returns the broadcaster’s highlight videos.

curl -X GET 'https://api.twitch.tv/helix/videos?user_id=123456&type=highlight' \ (etc)

It seems to me most in the spirit of the design of this project if both the /vod/ and /vodonly/ handles set type to archive in their twitch api calls, since they both claim to be about vods specifically, not highlights nor uploads. But if not both, then I definitely think at least /vodonly/ should be set to archive, to produce only vods!

Regards, and thanks for your time.

sn-o-w commented 1 year ago

@wyattscarpenter This is pretty easy to fix for your needs.

https://github.com/lzeke0/TwitchRSS/blob/master/TwitchRSS/twitchrss.py#L31

Have a look at line 31 of twitchrss.py -> change from type=all to type=archive

Btw, if you also need a working /vod/ handle, you need to cherry-pick this commit: https://github.com/sn-o-w/TwitchRSS/commit/ab95fae23e065f232c23c07f32bf60ab846cc020

Twitch made some changes on their side and the above commit is needed now for TwitchRSS to properly detect when a channel goes live.