SlyGuy Addons: Smart URL Actions

All SlyGuy Addons support: Smart URL Actions

This allows you to specify URL patterns that then have various actions applied to them.

 They can be applied to all add-ons and or to a single addon.

All SlyGuy addon urls used internally (talking to the various APIs etc) or used for media playback are eligible.

I personally use this with my Smart DNS provider (dns4me.net) to automatically apply their smart dns functionality without requiring changes to dns settings on any of my devices. As I can apply it on per add-on basis it allows for different services that use the same domains to both work. This is not possible when using router / device dns. eg. 9Now and TVNZ (both use same brightcove host). I can just add a urls.txt for 9Now only so only it routes via the smart dns IP address and TVNZ traffic is untouched.

File to use

To apply to all add-ons, the file used is kodi/userdata/addon_data/script.module.slyguy/urls.txt
To apply to specific add-on, the file used is kodi/userdata/addon_data/{addon id}/urls.txt
(if these folders don't exist - run the addon once and it'll create them)

urls.txt is simple text file with a pattern & action - one per line.
The file is read from top to bottom and stops once a single url match is found.

If both a common and add-on urls.txt are found, the addons urls patterns take priority.
If none of those patterns match, it will then check the common patterns.

The format is
action pattern
action pattern
action pattern
(same as hosts file)

Available URL Patterns

The pattern is very basic and its a search match so if the pattern is found anywhere in the requested url - its chosen.

Examples

brightcove.com
matches: http://brightcove.com
matches: https://edge.api.brighcove.com/api/121?test=123

brightcove.com/api/
matches: https://edge.api.brighcove.com/api/121?test=123

Wildcard

There is also a wildcard character which is *
This matches 0 or more of any character.
This can be used like below:

http://*brightcove.com/api/
matches: http://edge.api.brighcove.com/api/121?test=123
doesnt match: https://edge.api.brightcove.com/

Available Actions

DNS Rewrite

This overrides the IP address resolution for the matching URL with a provided value

eg.
43.209.63.213 edge.api.brightcove.com

If the url matches, the domain name IP lookup will be overridden with the provided IP address. The format is compatible with hosts files format.

Proxy

This routes the matched URL via the provided proxy.
The proxy url must start with > so the script can identify it as a proxy url. 

eg.
>socks5://user:[email protected]:port edge.api.brightcove.com
>http://host:port edge.api.brightcove.com

Replace

This replaces the matched URL with a provided value (uses regex sub).
This is handy to force certain CDNs for various services.

eg.
vodhds-au.akamaihd.net vodhds-*.akamaihd.net

With the above, if the url was https://vodhds-us.akamaihd.net/test.m3u8, it will be changed to https://voddhs-au.akamaihd.net/test.m3u8
This is great if your Smart DNS provider doesn't have a domain name that you found is being used. 

URL

This will download the provided url and use it's patterns.
It is defined by just putting the url on it's own line.

eg.
https://dns4me.net/api/v2/get_hosts/hosts/214852da-2f80-48f9-be62-888642d6e5e3

When the urls.txt file is being loaded - it will download the above URL and add it's contents to it's list of patterns.

With dns4me, its as easy as copying in your Raw Host File API URL from their website into a urls.txt file inside your addons addon data directory. And that's it. It will be downloaded and cached for 5minutes. No more changing DNS settings on your device or router.

Discussion

Support