update URL for streams

This commit is contained in:
Igor Katson 2024-04-29 19:01:04 +01:00
parent da3e199c91
commit ea2dfd0500
7 changed files with 25 additions and 8 deletions

View file

@ -97,3 +97,4 @@ Streaming:
Other:
- [ ] keepalive is useless, the tieout is 120s, and read timeout is 10s. Need to send keepalive only if nothing was done recently.
- [x] url should have the filename

View file

@ -281,7 +281,11 @@ impl HttpApi {
.route("/torrents/:id/stats", get(torrent_stats_v0))
.route("/torrents/:id/stats/v1", get(torrent_stats_v1))
.route("/torrents/:id/peer_stats", get(peer_stats))
.route("/torrents/:id/stream/:file_id", get(torrent_stream_file));
.route("/torrents/:id/stream/:file_id", get(torrent_stream_file))
.route(
"/torrents/:id/stream/:file_id/*filename",
get(torrent_stream_file),
);
if !self.opts.read_only {
app = app

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@
"css": [
"assets/index-74bd798d.css"
],
"file": "assets/index-80d6e7c6.js",
"file": "assets/index-fcae4638.js",
"isEntry": true,
"src": "index.html"
}

View file

@ -166,7 +166,11 @@ export interface RqbitAPI {
listTorrents: () => Promise<ListTorrentsResponse>;
getTorrentDetails: (index: number) => Promise<TorrentDetails>;
getTorrentStats: (index: number) => Promise<TorrentStats>;
getTorrentStreamUrl: (index: number, file_id: number) => string | null;
getTorrentStreamUrl: (
index: number,
file_id: number,
filename?: string | null,
) => string | null;
uploadTorrent: (
data: string | File,
opts?: AddTorrentOptions,

View file

@ -161,7 +161,7 @@ const FileTreeComponent: React.FC<{
torrentId != null &&
/\.(mp4|mkv|avi)$/.test(file.filename)
) {
return API.getTorrentStreamUrl(torrentId, file.id);
return API.getTorrentStreamUrl(torrentId, file.id, file.filename);
}
};

View file

@ -140,7 +140,15 @@ export const API: RqbitAPI & { getVersion: () => Promise<string> } = {
const r = await makeRequest("GET", "/");
return r.version;
},
getTorrentStreamUrl: (index: number, file_id: number) => {
return apiUrl + `/torrents/${index}/stream/${file_id}`;
getTorrentStreamUrl: (
index: number,
file_id: number,
filename?: string | null,
) => {
let url = apiUrl + `/torrents/${index}/stream/${file_id}`;
if (!!filename) {
url += `/${filename}`;
}
return url;
},
};