Introduction - Atelier-Shiori/detectstream GitHub Wiki

What is detectstream

Detectstream is a Cocoa Framework for macOS that takes all the URLs and titles from open windows and tabs and detect Anime being stream on legal streaming sites and spit out the series title and episode. It works like this:

  • Check to see if Safari, Webkit, Omniweb, Roccat Browser or Chrome is open. If there are any open windows and tabs, it will take the title and URL. Using regular expressions, it will check if it's a streaming site. If so, it's added to a temporary array. If not, it's ignored.
  • Next, it goes through another round of regular expressions, but this time it's specific to a specific streaming site. Each streaming site will have a separate set of patterns. If the information is valid, it will be put in the final array. For site that requires scraping, it will find the information necessary by using regular expressions, parse it and add it to the final array.
  • Lastly, the final array is put into a dictionary with a key called "result" and is outputted as a NSDictionary object. If there is no windows or match, the output for result will come out as null. The detectstream command line tool is meant for debug or legacy purposes.

Detectstream also have support for Manga from legal sites, but support is currently limited. You can determine if the detected item is an anime or manga through it's type field.

Note: For Netflix, it will use scraping with regular expressions to first get the episode ID (unique identifier that denotes an episode with the meta data) or in the URL. Then it will scrape for the JSON data encoded in Base64, decode it and then use that data to get the correct episode number. Season is determined by the enumeration integer.

Here are the example of the outputs from the currently working program with the browser watching an episode of Kill la Kill Episode 1 in Safari:

{"result":[{"browser":"Safari","title":"Kill la Kill","season":1,"site":"netflix","episode":1, "type":"anime}]}

For Manga, it will look like this: {"result":[{"browser":"Safari","title":"Tales of Wedding Rings","chapter":34,"site":"crunchyroll","type":"manga"}]}

This will be the output when there is no match:

{"result":null}

What Sites do you Support?

detectstream currently supports these sites:

Anime

Safari, Webkit, Chrome, Roccat Browser and Omniweb: Crunchyroll, AnimeNewsNetwork, AnimeLab, Viz Neon Valley, Viewster, Wakanim, Funimation, Netflix, Hidive, VRV, and Plex.tv Media Server (locally and on the web).

Chrome and Safari only (requires Javascript Execution): Viewster, Amazon Prime Video (For Safari, you need to have "Enable Javascript from Apple Events" enabled in the Developer Menu)

Manga

Safari, Webkit, Chrome, Roccat Browser and Omniweb: Crunchyroll

Note that detectstream is only meant for legal streaming sites, but custom rule support will come in the future.

Is my browser supported?

As long it has Applescript capabilities and you can see the information for the tab and window or execute javascript, then yes.

Fluid (Site specific browser) will not be supported since I couldn't get scripting bridge working and that it generates a new bundle identifier when you create a new site specific browser. iCab is also not supported since the Applescript support it comes with does not provide easy access to title and URL. Firefox and Opera does not have Applescript support at all.

What streaming sites I can't support?

  • Any Illegal Streaming Sites
  • Animax UK - Does not provide episode number for all their titles when there is an episode title

Can this be ported to Snow Leopard?

Yes, but you would need to use a different regular expressions class since NSRegularExpressions only exist in Lion or later.

May I use the regular expressions from this program?

Yes, the program is licensed under the MIT License.

Why Amazon Prime Video/Viewster Detection not working in Safari?

Since macOS Sierra, execution of JavaScript through AppleScript have been disabled by default. The option "Allow JavaScript from Apple Events" can be enabled in the Develop menu.