Skip to content

Commit d6dc015

Browse files
author
Kevin Souza
committed
readme, changing some if else to match
1 parent 7e23557 commit d6dc015

4 files changed

Lines changed: 33 additions & 34 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ A Twitch and YouTube frontend written in Rust using Tauri and SvelteKit.
2727
2828
## Features
2929

30-
- Import YouTube subscriptions.
31-
- Add users to your stream and video feeds.
30+
- Import YouTube subscriptions. (Accepts a `csv` file separated by Channel ID, URL, Title)
31+
- Add users to your stream and videos feeds.
3232
- Watch content in any of the available resolutions.
3333
- View Twitch chat with 7tv and BetterTTV emotes.
3434
- Block ads.
@@ -38,7 +38,7 @@ A Twitch and YouTube frontend written in Rust using Tauri and SvelteKit.
3838

3939
> All installers (`exe`, `deb`, `rpm`) are provided in a small zip file.
4040
41-
[Quick download.](https://nightly.link/Kyagara/rt/workflows/build.yaml/main/bundles.zip)
41+
[Quick download.](https://nightly.link/Kyagara/rt/workflows/build.yaml/main/bundles.zip) (does not require GitHub account).
4242

4343
Github Actions builds are available [here](https://github.com/Kyagara/rt/actions).
4444

@@ -65,7 +65,7 @@ If the app is not running, it will be started with the URL as an argument, if it
6565
- `rt://twitch/zfg1`
6666
- `rt://www.twitch.tv/zfg1`
6767

68-
If using extensions like [LibRedirect](https://github.com/libredirect/browser_extension), you can set a frontend for YouTube like Invidious and set the instance URL to `rt://yt`. The same can be done for Twitch, you can set the frontend to SafeTwitch and set the instance URL to `rt://tw`.
68+
If you are using extensions like [LibRedirect](https://github.com/libredirect/browser_extension), you can set a frontend for YouTube like Invidious and set the instance URL to `rt://`. The same can be done for Twitch, you can set the frontend to SafeTwitch and set the instance URL to `rt://`.
6969

7070
### Paths
7171

@@ -85,21 +85,23 @@ Logs:
8585

8686
`YouTube`:
8787

88+
The feed uses YouTube's rss feed to retrieve videos to avoid rate limits, this sadly does not contain video duration.
89+
8890
Using the excellent [RustyPipe](https://crates.io/crates/rustypipe) library to interact with YouTube, its recommended to install [rustypipe-botguard](https://crates.io/crates/rustypipe-botguard) to use a YouTube player instead of the embedded one.
8991

9092
```bash
9193
cargo install rustypipe-botguard
9294
```
9395

94-
The feed uses YouTube's rss feed to retrieve videos to avoid rate limits, this sadly does not contain video duration.
96+
The watch page will try to use RustyPipe to retrieve a YouTube player, if it fails, it will use Vidstack's YouTube [provider](https://vidstack.io/docs/player/api/providers/youtube/) to play videos via embeds, this fallback has the drawbacks of not being able to play videos that disallows embedding and not being able to select a video quality. You have the option to switch between them in the Watch page.
9597

96-
The watch page will try to use RustyPipe to retrieve a YouTube player, if it fails, it will use Vidstack's YouTube [provider](https://vidstack.io/docs/player/api/providers/youtube/) to play videos via embeds, this fallback has the drawbacks of not being able to play videos that disallows embedding and not being able to select a video quality. You can also switch between them.
98+
The player currently doesn't show the quality selection correctly, as there are multiple codecs for the same quality, which will show duplicates.
9799

98100
`Twitch`:
99101

100-
The player uses a custom [hls.js](https://github.com/video-dev/hls.js/) loader that communicates with the backend to modify the streams m3u8 manifests, this is what allows for ad blocking as the backend can detect ads and switch to a backup stream until ads are over, this was inspired on [TwitchAdSolutions](https://github.com/pixeltris/TwitchAdSolutions) method of switching streams.
102+
The player uses a custom [hls.js](https://github.com/video-dev/hls.js/) loader that communicates with the backend to retrieve and modify the m3u8 manifests, this is what allows for ad blocking as the backend can detect ads and switch to a backup stream until ads are over, this was inspired by [TwitchAdSolutions](https://github.com/pixeltris/TwitchAdSolutions) method of switching streams.
101103

102-
The backend uses queries from the Twitch API to retrieve user data and stream playback.
104+
The backend uses GQL queries from the internal Twitch API to retrieve user data and stream playback.
103105

104106
## TODO
105107

src-tauri/src/twitch/chat.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,24 @@ pub async fn join_chat(
154154
continue;
155155
}
156156

157-
let color = if let Some(color) = caps.name("color") {
158-
color.as_str().to_string()
159-
} else {
160-
String::new()
157+
let color = match caps.name("color") {
158+
Some(color) => color.as_str().to_string(),
159+
_ => String::new(),
161160
};
162161

163-
let display_name = if let Some(display_name) = caps.name("display_name") {
164-
display_name.as_str().to_string()
165-
} else {
166-
continue;
162+
let display_name = match caps.name("display_name") {
163+
Some(display_name) => display_name.as_str().to_string(),
164+
_ => continue,
167165
};
168166

169-
let first_msg = if let Some(first_msg) = caps.name("first_msg") {
170-
first_msg.as_str() != "0"
171-
} else {
172-
false
167+
let first_msg = match caps.name("first_msg") {
168+
Some(first_msg) => first_msg.as_str() != "0",
169+
_ => false,
173170
};
174171

175-
let content = if let Some(content) = caps.name("message") {
176-
content.as_str().trim_end()
177-
} else {
178-
continue;
172+
let content = match caps.name("message") {
173+
Some(content) => content.as_str().trim_end(),
174+
_ => continue,
179175
};
180176

181177
let fragments = parse_chat_fragments(content, &user_emotes);

src-tauri/src/twitch/proxy.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ pub async fn proxy_stream(
5353

5454
let mut stream_state = {
5555
let lock = STREAM_STATE.lock().await;
56+
5657
let state = lock.get(&window_label).unwrap_or(&StreamState {
5758
using_backup: false,
5859
main_stream_url: None,
5960
backup_stream_url: None,
6061
});
62+
6163
state.clone()
6264
};
6365

@@ -169,7 +171,9 @@ async fn fetch_playlist_text(url: &str) -> Result<String> {
169171
async fn fetch_main_stream(username: &str, stream_state: &mut StreamState) -> Result<String> {
170172
let Some(main_url) = stream_state.main_stream_url.clone() else {
171173
error!("Main stream URL not found. Falling back to backup stream.");
174+
172175
let backup_url = fetch_backup_stream_url(username).await?;
176+
173177
return fetch_playlist_text(&backup_url).await;
174178
};
175179

@@ -186,12 +190,9 @@ async fn fetch_main_stream(username: &str, stream_state: &mut StreamState) -> Re
186190
}
187191

188192
async fn fetch_backup_stream_url(username: &str) -> Result<String> {
189-
let url = match stream::fetch_stream_playback(username, true).await {
190-
Ok(url) => url,
191-
Err(err) => {
192-
return Err(anyhow!("Fetching backup stream: {err}"));
193-
}
194-
};
193+
let url = stream::fetch_stream_playback(username, true)
194+
.await
195+
.map_err(|err| anyhow!("Fetching backup stream: {err}"))?;
195196

196197
let body = fetch_playlist_text(&url).await?;
197198

src-tauri/src/youtube/video.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ pub async fn fetch_video(video_id: &str) -> Result<WatchPageVideo, String> {
165165
let channel = get_channel(&details.channel);
166166
let chapters = get_chapters(&details.chapters);
167167

168-
let (video, audio, subtitles) = if !using_embed {
168+
let (video, audio, subtitles) = if using_embed {
169+
(Vec::new(), Vec::new(), Vec::new())
170+
} else {
169171
let player = results
170172
.1
171173
.unwrap()
@@ -176,12 +178,10 @@ pub async fn fetch_video(video_id: &str) -> Result<WatchPageVideo, String> {
176178
let (video, audio) = get_player_formats(&player.video_only_streams, &player.audio_streams);
177179

178180
(video, audio, subtitles)
179-
} else {
180-
(Vec::new(), Vec::new(), Vec::new())
181181
};
182182

183183
let watch_page_video = WatchPageVideo {
184-
id: details.id.clone(),
184+
id: details.id,
185185
metadata,
186186
channel,
187187
chapters,

0 commit comments

Comments
 (0)