BETA Clips Detection


#1

As of the 22nd August 2017 build, a BETA for automatically detecting Twitch clips has been added.

First, the warning about the accuracy of this:


There are restrictions on this due to the Twitch API. Twitch allows us to poll the clips from the “day” (assuming this is the current day, not sure if it is last 24 hours or not though). We poll 100 of the clips - this is the maximum that Twitch allows. We then scan over all of the clips for the newest one. If this is newer than the last one in the database, then an event will be sent and a message presented in chat.

Keep in mind that if you have over 100 clips in the “day” period, that the newest one will only bubble up if it has more views than the last newest clip. This, unfortunately is what Twitch returns and we hope they provide a better endpoint in the future.

This means that it is possible that the latest clip is NOT automatically displayed in chat! Do not open a bug report ticket if you have over 100 clips within the “day” period and the latest does not show up. The first thing we will ask and perhaps check is how many clips you have, if you have 100, we will reply as such and close the request.

Also note that during some testing, it seems that the Twitch API takes 3+ minutes to reply. In one test, it took almost 10 minutes. So, please, keep in mind that the Twitch API does not return data as soon as someone creates a clip.


Now that the warning has been presented.

To toggle this feature, run the following command with an admin account or above (unless you change the permission): !clipstoggle

You may set the message with !clipsmessage. It supports tags of (name) and (url).

Please note that as the data is primed, that the last clip in your channel will be displayed in chat, if it exists in the “day” period as defined by Twitch.

Once this is out of a BETA soak period, we will add Discord support and Control Panel support. For right now though, as it is BETA, it is not entirely complete and perhaps unstable.


New Twitch Clip Created Alert
The lastclip not working properly
Clips not showing up in discord at all
Twitter posts not making it to Discord
#3

Looks like an great feature.


#4

when you do clipsmessage it says bits message as a reply

Also if this makes any sence?

[08-22-2017 @ 15:50:50.741 GMT] [ERROR] [onEvent()@ScriptEventManager.java:79] Failed to dispatch event tv.phantombot.event.twitch.clip.TwitchClipEvent

#5

The message was already fixed. I am not getting the other error.


#6

Hooking up to a channel with Clips, as mine doesn’t have any right now:

[08-22-2017 @ 10:07:30.489 MDT] >> check clips
[08-22-2017 @ 10:07:30.921 MDT] [CHAT] OMG_Silver created a clip: https://clips.twitch.tv/BetterGlutenFreeNuggetsRaccAttack?tt_medium=clips_api&tt_content=url
lastclip
[08-22-2017 @ 10:07:34.940 MDT] [CHAT] @IllusionaryBot, Last Clip: https://clips.twitch.tv/BetterGlutenFreeNuggetsRaccAttack?tt_medium=clips_api&tt_content=url
topclip
[08-22-2017 @ 10:07:35.914 MDT] [CHAT] @IllusionaryBot, Today's Most Viewed Clip: https://clips.twitch.tv/BetterGlutenFreeNuggetsRaccAttack?tt_medium=clips_api&tt_content=url

[08-22-2017 @ 10:08:32.818 MDT] >> check clips
mods
[08-22-2017 @ 10:08:58.139 MDT] [CHAT] @IllusionaryBot, Mods in channel: illusionarybot, scaniatv

#7

Then set back to my channel, note that this fires every other time TwitchCache::updateCache fires:

debugon
[08-22-2017 @ 10:11:11.827 MDT] [CONSOLE] Executing debugon: Enable Debug Mode
[08-22-2017 @ 10:11:19.747 MDT] [DEBUG] [updateCache()@TwitchCache.java:227] TwitchCache::updateCache   <--
[08-22-2017 @ 10:11:23.705 MDT] [DEBUG] [updateCache()@TwitterCache.java:155] TwitterCache::updateCache
[08-22-2017 @ 10:11:23.805 MDT] [DEBUG] [getUserTimeline()@TwitterAPI.java:215] Polling Data
[08-22-2017 @ 10:11:38.266 MDT] [DEBUG] [updateCache()@DonationsCache.java:131] DonationsCache::updateCache
[08-22-2017 @ 10:11:38.302 MDT] [DEBUG] [updateCache()@FollowersCache.java:114] FollowersCache::updateCache
[08-22-2017 @ 10:11:39.015 MDT] [DEBUG] [updateCache()@TwitterCache.java:155] TwitterCache::updateCache
[08-22-2017 @ 10:11:39.097 MDT] [DEBUG] [getRetweetsOfMe()@TwitterAPI.java:309] Polling Data
[08-22-2017 @ 10:11:39.423 MDT] [DEBUG] [getUserTimeline()@TwitterAPI.java:215] Polling Data
[08-22-2017 @ 10:11:50.803 MDT] [DEBUG] [updateCache()@TwitchCache.java:227] TwitchCache::updateCache   <--
[08-22-2017 @ 10:11:54.488 MDT] [DEBUG] [updateCache()@TwitterCache.java:155] TwitterCache::updateCache
[08-22-2017 @ 10:11:54.576 MDT] [DEBUG] [getUserTimeline()@TwitterAPI.java:215] Polling Data
[08-22-2017 @ 10:12:08.676 MDT] [DEBUG] [updateCache()@DonationsCache.java:131] DonationsCache::updateCache
[08-22-2017 @ 10:12:08.768 MDT] [DEBUG] [updateCache()@FollowersCache.java:114] FollowersCache::updateCache
[08-22-2017 @ 10:12:09.787 MDT] [DEBUG] [updateCache()@TwitterCache.java:155] TwitterCache::updateCache
[08-22-2017 @ 10:12:09.876 MDT] [DEBUG] [getUserTimeline()@TwitterAPI.java:215] Polling Data
[08-22-2017 @ 10:12:22.089 MDT] [DEBUG] [updateCache()@TwitchCache.java:227] TwitchCache::updateCache   <--

#8

seems to have fixed itself :slight_smile: thanks :slight_smile: … am i getting this wrong or is not ment to post the clips every time someone makes one cus its not???

Or maybe its trying too i got the error again (Revision: c444cf7)


#9

Not sure, you could wait for the next Nightly Build, but I wasn’t getting these errors last night nor today.


#10

Oh now its working but its not sending the click when its made it just saves it then i have to do the !lastclip command to view it is that how its intented to be?


#11

It doesn’t detect the moment the click is made (we can’t hit the API like that). It is on a 60 second delay and therefore, might not always get every clip. It scans an ID for the newest one, and ignores anything not newer than that.


#12

I have hooked up to a large channel and will watch it.


#13

ok other wise ill just wait until tomorrow as its getting it fine but its erroring when its trying to post it info chat :slight_smile:


#14

So, what I said would happen in the original post is what happens. When I use a large channel, a new clip has to get enough views to onto the list of 100. I made a couple of clips, and my first one got triggered only after it got a more than 1 view. I do not know what channel you are using, so I would need to know so that I can scan the clips. Also, there is a delay in the Twitch API, it took 3+ minutes for my clip to appear in the API call. Please remember that the Twitch API is never immediate, it is cached data and takes a while to propagate.

Anyway, I then went to a smaller channel and made clips.

I made a clip then fired up my bot, with some additional debug statements:

[08-22-2017 @ 10:58:42.213 MDT] >> check clips
[08-22-2017 @ 10:58:42.213 MDT] >> has clips
[08-22-2017 @ 10:58:42.214 MDT] >> 0
[08-22-2017 @ 10:59:44.431 MDT] >> check clips
[08-22-2017 @ 10:59:44.431 MDT] >> has clips
[08-22-2017 @ 10:59:44.431 MDT] >> 0
[08-22-2017 @ 11:00:46.824 MDT] >> check clips
[08-22-2017 @ 11:00:46.824 MDT] >> has clips
[08-22-2017 @ 11:00:46.824 MDT] >> 1
[08-22-2017 @ 11:00:46.829 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:00:46.829 MDT] >> largest was 0 is 117738694
[08-22-2017 @ 11:00:46.836 MDT] [CHAT] IllusionaryOne created a clip: https://clips.twitch.tv/FriendlyMuddyChamoisBlargNaut?tt_medium=clips_api&tt_content=url
[08-22-2017 @ 11:01:48.816 MDT] >> check clips
[08-22-2017 @ 11:01:48.816 MDT] >> has clips
[08-22-2017 @ 11:01:48.816 MDT] >> 1
[08-22-2017 @ 11:01:48.821 MDT] >> 0 << >> 117738694

Then I made another clip at about 11:01:

[08-22-2017 @ 11:01:48.816 MDT] >> check clips
[08-22-2017 @ 11:01:48.816 MDT] >> has clips
[08-22-2017 @ 11:01:48.816 MDT] >> 1
[08-22-2017 @ 11:01:48.821 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:02:50.758 MDT] >> check clips
[08-22-2017 @ 11:02:50.758 MDT] >> has clips
[08-22-2017 @ 11:02:50.758 MDT] >> 1
[08-22-2017 @ 11:02:50.762 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:03:52.613 MDT] >> check clips
[08-22-2017 @ 11:03:52.613 MDT] >> has clips
[08-22-2017 @ 11:03:52.614 MDT] >> 1
[08-22-2017 @ 11:03:52.618 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:04:54.612 MDT] >> check clips
[08-22-2017 @ 11:04:54.612 MDT] >> has clips
[08-22-2017 @ 11:04:54.612 MDT] >> 1
[08-22-2017 @ 11:04:54.615 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:05:56.582 MDT] >> check clips
[08-22-2017 @ 11:05:56.582 MDT] >> has clips
[08-22-2017 @ 11:05:56.582 MDT] >> 1
[08-22-2017 @ 11:05:56.586 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:06:58.425 MDT] >> check clips
[08-22-2017 @ 11:06:58.425 MDT] >> has clips
[08-22-2017 @ 11:06:58.425 MDT] >> 1
[08-22-2017 @ 11:06:58.428 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:08:00.420 MDT] >> check clips
[08-22-2017 @ 11:08:00.420 MDT] >> has clips
[08-22-2017 @ 11:08:00.421 MDT] >> 1
[08-22-2017 @ 11:08:00.425 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:09:02.390 MDT] >> check clips
[08-22-2017 @ 11:09:02.391 MDT] >> has clips
[08-22-2017 @ 11:09:02.391 MDT] >> 1
[08-22-2017 @ 11:09:02.395 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:10:04.551 MDT] >> check clips
[08-22-2017 @ 11:10:04.552 MDT] >> has clips
[08-22-2017 @ 11:10:04.552 MDT] >> 2
[08-22-2017 @ 11:10:04.556 MDT] >> 0 << >> 117738694
[08-22-2017 @ 11:10:04.556 MDT] >> 1 << >> 117739682
[08-22-2017 @ 11:10:04.556 MDT] >> largest was 117738694 is 117739682
[08-22-2017 @ 11:10:04.562 MDT] [CHAT] IllusionaryOne created a clip: https://clips.twitch.tv/InterestingDullKumquatDeIlluminati?tt_medium=clips_api&tt_content=url

Note how long it took Twitch to return the data – 9 minutes. This isn’t due to PhantomBot, this is due to the Twitch API.


#15

i just tested it on my own and it worked 100% within 45 seconds so just re testing it on the other channel and it seems to have worked after 7 mins :slight_smile:


#16

Yeah, like I said, the Twitch API can be interesting. Do remember that it is cached data and can take a while to propagate, I seem to get things sometimes in less than a minute, other times, within 10 minutes.

Would you mind telling me the channel that it isn’t working in? I can check the data to make sure there isn’t something wonky in it that I need to account for. Although, I have scanned about 10 different channels now and it’s been good. That isn’t to say that Twitch doesn’t send junk at times though.


#17

the channel was chrisishd i copy and pasted his db and botlogin to my version and it worked fine could could of been his install messed up


#18

Ok. I will check the API end point.

Update: Looks fine when I call the endpoint directly and scan over it. If you say it is working now, then could have just been something in his install then.


#19

Is there some witchcraft involved with getting this to work? I can query the twitch api and it says theres a new clip (using the exact api call the bot makes) however nothing ever shows up in Discord.

I have the clip handler enabled, the bot can chat in the channel I’m trying to use (i made a test command to see if it would post there and it does).


#20

You’ll have to enable the module for Twitch and have the toggle on as well for this feature to work in Discord. If you really don’t want to have the clips posted in your Twitch chat, you can just enable the toggle for clips for Twitch, then disable the Twitch module for this and it should still post in Discord afterwards.

I’ll push a real fix for this for our next release.


#21

Cool, thanks for that, it works now :smiley:

Is there something I can edit to get it to post a working link? It doesn’t post the https:// in front of the url so it doesn’t actually link anything.