City17
A serverless Rust function designed to avoid ads on Twitch
Install / Use
/learn @AlyoshaVasilieva/City17README
I've switched to working on luminous-ttv, which so far is both easier to use and more reliable.
City17
A Rust serverless function to retrieve and relay a playlist for Twitch livestreams/VODs.
By running this in specific countries and using a browser extension to redirect certain network requests to this function, Twitch will not display any ads.
I don't provide any pre-built version of this, you have to set it up yourself.
My rough estimate is that a few hundred to a few thousand users can be supported while staying inside the free tier's limits, but I wouldn't recommend publicizing your function unless you actually understand how the pricing works. If you're the only user you won't need to pay anything. (Supposedly there's no free tier on outbound bandwidth, but my bill in May was 0.000000 USD.)
You can probably run this as an actual server, but I haven't tested that because that costs money.
<sup><sub>(I don't remember why I named this City17.)</sub></sup>
Requirements
The function needs to be run in a country where Twitch doesn't serve ads. Countries currently known: Russia, China.
I don't know of any serverless provider that operates in Russia, and supports Rust, and allows use by people outside Russia. China has at least two providers that should work fine, one of which I've personally tested. (Some amount of GFW evasion takes place, since Twitch is blocked in China, but at least we can be pretty sure that Twitch won't start running ads there...?)
I've only successfully run this on Aliyun (Alibaba Cloud) from Chinese regions, and the code will require modifications to run on a different provider. (Except Azure if I managed to avoid breaking it after my initial tests there; there's a feature flag.)
Tencent Cloud should also work with some minor modifications, but I've been unable to complete signup to test it.
Azure might work if any of its locations are non-ad countries. Twitch considers the UAE to be located inside the USA, so their Dubai location (UAE North) doesn't work. Azure doesn't allow use of their Chinese regions unless you're a business with a presence in China.
Building
If you're going to use Aliyun and do not intend to modify the code, download city17.zip
from the latest release and proceed to the setup instructions.
Run build.sh. Cannot be truly built in Windows due to ring, but cargo check and cargo build
work for checking the code. Ubuntu 20.04 via WSL works fine and is what I use.
Once city17.zip is built, see setup instructions below.
Requires:
- Rust installed via rustup
- The
x86_64-unknown-linux-musltarget for Rust (rustup target add x86_64-unknown-linux-musl) 7za(p7zip-fullon Debian and Ubuntu, can modify script to use normal zip command)musl-gcc(musl-tools)- Probably
build-essential
Aliyun setup instructions
- Sign up, enable function compute, etc. (I'm not creating a new account just to write down all the steps)
- Set the region to China (Shanghai). As far as I know this is the region closest to Tokyo, which is where one of Twitch's servers is.
- In the Function Compute menu, enter Services and Functions and create
a service named
a. (Or whatever you want, but you'll need to modify the code.) - Create a function:
- HTTP
- Named
prx - Custom Runtime
- Select the ZIP file
city17.zip - Give it 128MB of RAM and a 15-second timeout.
For future updates of the function, use the Code tab's "Upload Zip File".
(Or get fcli, set it up, and run update.sh after build.sh)
Under the Code tab, use the URL listed there to set up the browser extension.
It looks like https://################.cn-shanghai.fc.aliyuncs.com/2016-08-15/proxy/a/prx/;
you will need to add invoke to the end.
Issues
- If the shell scripts fail due to having Windows line endings, run
dos2unix build.sh
dos2unix update.sh
in your Linux shell. (This shouldn't happen.)
Extra reading
The streamlink Twitch plugin has all the info needed in order to learn how to connect to Twitch and get the M3U8 playlist. Some of it doesn't quite match what Twitch is doing now, so watch a Twitch stream normally and look at the network requests your browser makes.
License
GNU GPLv3.
Related Skills
clearshot
Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.
openpencil
2.1kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
openpencil
2.1kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
ui-ux-designer
Use this agent when you need to design, implement, or improve user interface components and user experience flows. Examples include: creating new pages or components, improving existing UI layouts, implementing responsive designs, optimizing user interactions, building forms or dashboards, analyzing existing UI through browser snapshots, or when you need to ensure UI components follow design system standards and shadcn/ui best practices.\n\n<example>\nContext: User needs to create a new dashboard page for team management.\nuser: "I need to create a team management dashboard where users can view team members, invite new members, and manage roles"\nassistant: "I'll use the ui-ux-designer agent to design and implement this dashboard with proper UX considerations, using shadcn/ui components and our design system tokens."\n</example>\n\n<example>\nContext: User wants to improve the user experience of an existing form.\nuser: "The signup form feels clunky and users are dropping off. Can you improve it?"\nassistant: "Let me use the ui-ux-designer agent to analyze the current form UX and implement improvements using our design system and shadcn/ui components."\n</example>\n\n<example>\nContext: User wants to evaluate and improve existing UI.\nuser: "Can you take a look at our pricing page and see how we can make it more appealing and user-friendly?"\nassistant: "I'll use the ui-ux-designer agent to take a snapshot of the current pricing page, analyze the UX against Notion-inspired design principles, and implement improvements using our design tokens."\n</example>
