docs: fresh screenshots from the fake world, and a mock that can paint it
The README screenshots were from 2026-10-15 and showed a UI that no longer
exists (sidebar order, privacy badges, no progress lines). They also came
from the old mock, which proxied someone else's instance — that is how
they got real pictures, and it also meant the pictures could drift from
what the tests know.
This re-shoot uses the SAME fixture the tests use, so nothing in the
README can show a world the tests do not describe, and no personal
content ends up in a public repo. To make that possible the mock now:
- renders deterministic 16:9 covers (gradient + shapes + the video's
title) instead of depending on somebody's thumbnails;
- serves the routes the list screens need (history, subscriptions, own
videos, search, config, video detail with userHistory, subscribe
state, watching) — mirroring FakePeertube.kt;
- answers account-scoped channel lists and strips the "@host" suffix, so
rows and counts come out right;
- serves a small generated MP4 as the media, so the player really plays.
The fixture gained per-channel title lists (cycled with a part number in
both generators), which is what makes a card say "Moderation basics"
instead of "chronicles video 12" — and the screenshot covers no longer
repeat one channel's name 37 times.
Also fixed along the way: the player's channel name and date ran together
("PeerTube Chronicles1 Oct 2026") whenever the API omits followersCount —
the gap is unconditional now.
27
README.md
|
|
@ -52,18 +52,28 @@ the full list.
|
|||
<img src="docs/screenshots/drawer.png" width="800" alt="Menu drawer with the destinations" />
|
||||
</p>
|
||||
|
||||
**My videos.** Everything you own, every privacy level, with a badge on
|
||||
anything that isn't public.
|
||||
**My videos.** Everything you own, every privacy level. A non-public video says
|
||||
so everywhere its card appears, as a quiet letter at the card's right edge —
|
||||
**P**rivate, **I**nternal, **U**nlisted — while public videos stay unmarked.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/screenshots/myvideos.png" width="800" alt="My videos grid with Private and Internal badges" />
|
||||
<img src="docs/screenshots/myvideos.png" width="800" alt="My videos grid with the P, I and U privacy letters on non-public cards" />
|
||||
</p>
|
||||
|
||||
**Search.** One field, two questions: *what* to look for — videos, or channels
|
||||
as their own results — and *where*: this server, or the federated index
|
||||
(Vidiverse). Cards that did not come from your instance carry a small ↗, because
|
||||
those may play from another server.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/screenshots/search.png" width="800" alt="Search screen with the Videos/Channels and Local/Vidiverse scopes and its results" />
|
||||
</p>
|
||||
|
||||
**Channels.** One row per owner, with video, subscriber and play counts on
|
||||
every card.
|
||||
every card, and the owner's own card at the end of the row.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/screenshots/channels.png" width="800" alt="Channels screen with channel cards" />
|
||||
<img src="docs/screenshots/channels.png" width="800" alt="Channels screen: one row per owner, ending with the owner's own card" />
|
||||
</p>
|
||||
|
||||
Open a channel for its banner, its stats and all its videos — with a Subscribe
|
||||
|
|
@ -82,6 +92,13 @@ left off survives closing the app.
|
|||
<img src="docs/screenshots/player.png" width="800" alt="Player with controls, seek bar and title" />
|
||||
</p>
|
||||
|
||||
The info panel scrolls one line per D-pad press and highlights the link that OK
|
||||
will open, so a long description stays readable from the couch.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/screenshots/info.png" width="800" alt="Info panel over the player, with the highlighted link in the description" />
|
||||
</p>
|
||||
|
||||
## What it does
|
||||
|
||||
- **Sign in once.** The app trades your username and password for OAuth tokens
|
||||
|
|
|
|||
|
|
@ -11,19 +11,40 @@
|
|||
"name": "chronicles",
|
||||
"displayName": "PeerTube Chronicles",
|
||||
"videos": 37,
|
||||
"followers": 3
|
||||
"followers": 3,
|
||||
"titles": [
|
||||
"PeerTube 8.3: what changed",
|
||||
"Moderation basics",
|
||||
"Federation in practice",
|
||||
"Object storage pitfalls",
|
||||
"Upgrading a small instance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "shorts",
|
||||
"displayName": "Aaron Shorts",
|
||||
"videos": 113,
|
||||
"followers": 7
|
||||
"followers": 7,
|
||||
"titles": [
|
||||
"Unboxing the new mic",
|
||||
"Three minutes of rain",
|
||||
"Quick pasta",
|
||||
"Shelf build",
|
||||
"Night walk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "travels",
|
||||
"displayName": "Travels",
|
||||
"videos": 45,
|
||||
"followers": 12
|
||||
"followers": 12,
|
||||
"titles": [
|
||||
"Kyoto in the rain",
|
||||
"Alps by train",
|
||||
"Ferry to Jeju",
|
||||
"Desert road",
|
||||
"Harbour at dawn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "empty",
|
||||
|
|
@ -37,7 +58,12 @@
|
|||
"displayName": "Friend's Channel",
|
||||
"videos": 6,
|
||||
"followers": 4,
|
||||
"owner": "friend"
|
||||
"owner": "friend",
|
||||
"titles": [
|
||||
"Garden tour",
|
||||
"Home-made bread",
|
||||
"Fix your bike"
|
||||
]
|
||||
}
|
||||
],
|
||||
"playlists": [
|
||||
|
|
@ -47,4 +73,4 @@
|
|||
"videos": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ class FakePeertube {
|
|||
|
||||
private fun videoJson(channel: String, index: Int): String =
|
||||
"""{"id":${channel.hashCode().toLong() * 1000 + index},"uuid":"$channel-$index",
|
||||
"shortUUID":"$channel$index","name":"$channel video $index",
|
||||
"shortUUID":"$channel$index","name":"${titleOf(channel, index)}",
|
||||
"url":"https://${if (channel == foreignChannel) foreignHost else host}/videos/watch/$channel-$index",
|
||||
"publishedAt":"2026-10-01T00:00:00.000Z","views":${index + 1},
|
||||
"thumbnailPath":"/lazy-static/thumbnails/$channel-$index.png",
|
||||
|
|
@ -344,6 +344,31 @@ class FakePeertube {
|
|||
/** True when this shortUUID belongs to the foreign (mirrored) channel. */
|
||||
private fun isForeignOnly(short: String): Boolean = short.startsWith(foreignChannel)
|
||||
|
||||
/**
|
||||
* Fixture title for the n-th video of a channel: the channel's own list, cycled,
|
||||
* with a part number once the list runs out. Keeps the fake world readable ("PeerTube
|
||||
* 8.3: what changed" beats "chronicles video 12") without inventing content the
|
||||
* tests do not know about.
|
||||
*/
|
||||
private fun titleOf(channel: String, index: Int): String {
|
||||
val titles = titlesOf(channel)
|
||||
if (titles.isEmpty()) return "$channel video $index"
|
||||
val title = titles[index % titles.size]
|
||||
val part = index / titles.size
|
||||
return if (part == 0) title else "$title (part ${part + 1})"
|
||||
}
|
||||
|
||||
private fun titlesOf(channel: String): List<String> {
|
||||
for (i in 0 until channels.length()) {
|
||||
val c = channels.getJSONObject(i)
|
||||
if (c.getString("name") == channel) {
|
||||
val arr = c.optJSONArray("titles") ?: return emptyList()
|
||||
return (0 until arr.length()).map { arr.getString(it) }
|
||||
}
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
/** Fixture channel name -> owning account. */
|
||||
private fun ownerOf(channel: String): String {
|
||||
for (i in 0 until channels.length()) {
|
||||
|
|
|
|||
|
|
@ -240,12 +240,15 @@ fun PausedControls(
|
|||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
// Same stat icons as the Channels view: Groups = subscribers,
|
||||
// PlayArrow = views.
|
||||
// PlayArrow = views. The gaps are unconditional: without a
|
||||
// follower count (some instances omit it) the channel name and
|
||||
// the date used to run together — "PeerTube Chronicles1 Oct 2026".
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
detail.channel.followersCount?.let { followers ->
|
||||
InlineStat(Icons.Filled.Groups, followers)
|
||||
InlineStat(Icons.Filled.PlayArrow, detail.views)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
text = formatPublished(detail.publishedAt),
|
||||
color = Color(0xFFCCCCCC),
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 878 KiB After Width: | Height: | Size: 437 KiB |
|
Before Width: | Height: | Size: 584 KiB After Width: | Height: | Size: 341 KiB |
|
Before Width: | Height: | Size: 908 KiB After Width: | Height: | Size: 318 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 354 KiB |
BIN
docs/screenshots/info.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 452 KiB |
|
Before Width: | Height: | Size: 689 KiB After Width: | Height: | Size: 111 KiB |
BIN
docs/screenshots/search.png
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
tools/mock/media/demo.mp4
Normal file
|
|
@ -25,6 +25,8 @@ import argparse
|
|||
import json
|
||||
import pathlib
|
||||
import re
|
||||
import hashlib
|
||||
import io
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
|
|
@ -32,6 +34,64 @@ REPO = pathlib.Path(__file__).resolve().parents[2]
|
|||
DEFAULT_FIXTURE = REPO / "app/src/androidTest/assets/fixtures/peertube.json"
|
||||
|
||||
|
||||
def render_thumbnail(text: str, subtitle: str, size=(480, 270)) -> bytes:
|
||||
"""Deterministic 16:9 cover for a fake video: a soft two-tone gradient from the
|
||||
name's hash, a couple of translucent shapes, and the title in a band at the
|
||||
bottom. Self-contained on purpose — no external instance, nobody's personal
|
||||
content, and the same picture on every run."""
|
||||
import colorsys
|
||||
import math
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
digest = hashlib.sha256(text.encode()).digest()
|
||||
hue_a = digest[0] / 255.0
|
||||
hue_b = (hue_a + 0.10) % 1.0
|
||||
w, h = size
|
||||
|
||||
def rgb(hue, sat, val):
|
||||
r, g, b = colorsys.hsv_to_rgb(hue % 1.0, sat, val)
|
||||
return int(r * 255), int(g * 255), int(b * 255)
|
||||
|
||||
img = Image.new("RGB", size)
|
||||
draw = ImageDraw.Draw(img, "RGBA")
|
||||
for y in range(h):
|
||||
t = y / max(1, h - 1)
|
||||
draw.line([(0, y), (w, y)], fill=rgb(hue_a + (hue_b - hue_a) * t, 0.35, 0.55 - 0.18 * t))
|
||||
# a few soft shapes so the cover is not a flat gradient
|
||||
for i in range(3):
|
||||
cx = int(w * (0.2 + 0.3 * i + 0.05 * (digest[1 + i] / 255.0)))
|
||||
cy = int(h * (0.3 + 0.2 * ((digest[4 + i] / 255.0) - 0.5)))
|
||||
r = int(min(w, h) * (0.18 + 0.10 * (digest[7 + i] / 255.0)))
|
||||
cr, cg, cb = rgb(hue_b + 0.05 * i, 0.5, 0.85)
|
||||
draw.ellipse([cx - r, cy - r, cx + r, cy + r], fill=(cr, cg, cb, 42))
|
||||
# title band
|
||||
band_h = int(h * 0.30)
|
||||
draw.rectangle([0, h - band_h, w, h], fill=(0, 0, 0, 110))
|
||||
try:
|
||||
font = ImageFont.truetype("/usr/share/fonts/TTF/DejaVuSans-Bold.ttf", 26)
|
||||
font_small = ImageFont.truetype("/usr/share/fonts/TTF/DejaVuSans.ttf", 17)
|
||||
except OSError:
|
||||
font = font_small = ImageFont.load_default()
|
||||
words, lines, line = text.split(), [], ""
|
||||
for word in words:
|
||||
candidate = (line + " " + word).strip()
|
||||
if draw.textlength(candidate, font=font) > w - 40 and line:
|
||||
lines.append(line)
|
||||
line = word
|
||||
else:
|
||||
line = candidate
|
||||
if line:
|
||||
lines.append(line)
|
||||
y = h - band_h + 8
|
||||
for text_line in lines[:2]:
|
||||
draw.text((20, y), text_line, font=font, fill=(255, 255, 255))
|
||||
y += 30
|
||||
draw.text((20, h - 26), subtitle, font=font_small, fill=(220, 220, 220, 220))
|
||||
out = io.BytesIO()
|
||||
img.save(out, format="JPEG", quality=82)
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
class FakePeertube:
|
||||
def __init__(self, fixture_path: pathlib.Path, host_header: str):
|
||||
self.spec = json.loads(fixture_path.read_text())
|
||||
|
|
@ -52,6 +112,7 @@ class FakePeertube:
|
|||
}
|
||||
|
||||
def channel(self, c):
|
||||
owner = c.get("owner", self.owner["name"])
|
||||
return {
|
||||
"name": c["name"],
|
||||
"displayName": c["displayName"],
|
||||
|
|
@ -59,20 +120,45 @@ class FakePeertube:
|
|||
"followersCount": c.get("followers", 0),
|
||||
"avatars": [],
|
||||
"banners": [],
|
||||
"ownerAccount": self.account(),
|
||||
"ownerAccount": {
|
||||
"name": owner, "host": self.host,
|
||||
"displayName": owner if owner != self.owner["name"] else self.owner["displayName"],
|
||||
"avatars": [],
|
||||
},
|
||||
}
|
||||
|
||||
def account_for(self, channel):
|
||||
owner = next((c.get("owner", self.owner["name"]) for c in self.channels
|
||||
if c["name"] == channel), self.owner["name"])
|
||||
if owner == self.owner["name"]:
|
||||
return self.account()
|
||||
return {"name": owner, "host": self.host,
|
||||
"displayName": owner, "avatars": []}
|
||||
|
||||
def title_of(self, channel, index):
|
||||
titles = next((c.get("titles", []) for c in self.channels if c["name"] == channel), [])
|
||||
if not titles:
|
||||
return f"{channel} video {index}"
|
||||
title = titles[index % len(titles)]
|
||||
part = index // len(titles)
|
||||
return title if part == 0 else f"{title} (part {part + 1})"
|
||||
|
||||
def video(self, channel, index):
|
||||
return {
|
||||
"id": abs(hash(channel)) % 100000 * 1000 + index,
|
||||
"uuid": f"{channel}-{index}",
|
||||
"shortUUID": f"{channel}{index}",
|
||||
"name": f"{channel} video {index}",
|
||||
"name": self.title_of(channel, index),
|
||||
"publishedAt": "2026-10-01T00:00:00.000Z",
|
||||
"views": index + 1,
|
||||
"thumbnailPath": f"/lazy-static/thumbnails/{channel}-{index}.jpg",
|
||||
"account": self.account(),
|
||||
"channel": {"name": channel, "displayName": channel, "host": self.host},
|
||||
"privacy": [{"id": 3, "label": "Private"}, {"id": 4, "label": "Internal"},
|
||||
{"id": 2, "label": "Unlisted"}, {"id": 1, "label": "Public"}][index % 4],
|
||||
"account": self.account_for(channel),
|
||||
"channel": {"name": channel,
|
||||
"displayName": next((c["displayName"] for c in self.channels
|
||||
if c["name"] == channel), channel),
|
||||
"host": self.host},
|
||||
}
|
||||
|
||||
def videos_for(self, channel, start, count):
|
||||
|
|
@ -80,12 +166,39 @@ class FakePeertube:
|
|||
return [self.video(channel, i) for i in range(start, min(start + count, total))]
|
||||
|
||||
def all_videos(self, start, count):
|
||||
every = []
|
||||
for c in self.channels:
|
||||
every.extend(self.videos_for(c["name"], 0, c["videos"]))
|
||||
# Round-robin across channels: the "new on this instance" row is a feed, and a
|
||||
# feed of one channel repeated 37 times is not what the screen looks like.
|
||||
lists = [self.videos_for(c["name"], 0, c["videos"]) for c in self.channels]
|
||||
every, index = [], 0
|
||||
while any(len(lst) > index for lst in lists):
|
||||
for lst in lists:
|
||||
if len(lst) > index:
|
||||
every.append(lst[index])
|
||||
index += 1
|
||||
return every[start:start + count]
|
||||
|
||||
# ---- routing ---------------------------------------------------------
|
||||
MEDIA = REPO / "tools/mock/media"
|
||||
|
||||
def media(self, path):
|
||||
"""The playable demo MP4 behind every fake video."""
|
||||
if path == "/lazy-static/videos/demo.mp4":
|
||||
return (self.MEDIA / "demo.mp4").read_bytes()
|
||||
return None
|
||||
|
||||
def image(self, path):
|
||||
"""Bytes for /lazy-static/thumbnails/<channel>-<index>.jpg and avatars."""
|
||||
m = re.match(r"^/lazy-static/thumbnails/(.+)-(\d+)\.jpg$", path)
|
||||
if m:
|
||||
channel, index = m.group(1), int(m.group(2))
|
||||
display = next((c["displayName"] for c in self.channels if c["name"] == channel), channel)
|
||||
return render_thumbnail(self.title_of(channel, index), display)
|
||||
m = re.match(r"^/lazy-static/avatars/(.+)\.(?:jpg|png)$", path)
|
||||
if m:
|
||||
name = m.group(1)
|
||||
return render_thumbnail(name, "avatar", size=(120, 120))
|
||||
return None
|
||||
|
||||
def respond(self, method, path, query):
|
||||
if path == "/api/v1/oauth-clients/local":
|
||||
return {"client_id": "fake-client", "client_secret": "fake-secret"}
|
||||
|
|
@ -100,18 +213,24 @@ class FakePeertube:
|
|||
if path == "/api/v1/users/me":
|
||||
return {"id": 1, "username": self.owner["name"],
|
||||
"displayName": self.owner["displayName"], "account": self.account()}
|
||||
if path == f"/api/v1/accounts/{self.owner['name']}/video-channels" or path.endswith("/video-channels"):
|
||||
return {"total": len(self.channels), "data": [self.channel(c) for c in self.channels]}
|
||||
# An account's OWN channels — filtered like the real API (and FakePeertube.kt):
|
||||
# an unfiltered answer put every channel into every row.
|
||||
m = re.match(r"^/api/v1/accounts/([^/]+)/video-channels$", path)
|
||||
if m:
|
||||
who = m.group(1)
|
||||
own = [c for c in self.channels if c.get("owner", self.owner["name"]) == who]
|
||||
return {"total": len(own), "data": [self.channel(c) for c in own]}
|
||||
m = re.match(r"^/api/v1/video-channels/([^/]+)/videos$", path)
|
||||
if m:
|
||||
channel = m.group(1)
|
||||
# the app addresses channels by full handle ("friends@host")
|
||||
channel = m.group(1).split("@")[0]
|
||||
start = int(query.get("start", ["0"])[0])
|
||||
count = int(query.get("count", ["100"])[0])
|
||||
total = next((c["videos"] for c in self.channels if c["name"] == channel), 0)
|
||||
return {"total": total, "data": self.videos_for(channel, start, count)}
|
||||
m = re.match(r"^/api/v1/video-channels/([^/]+)$", path)
|
||||
if m:
|
||||
channel = m.group(1)
|
||||
channel = m.group(1).split("@")[0]
|
||||
match = next((c for c in self.channels if c["name"] == channel), self.channels[0])
|
||||
return self.channel(match)
|
||||
if path == "/api/v1/videos":
|
||||
|
|
@ -119,6 +238,72 @@ class FakePeertube:
|
|||
count = int(query.get("count", ["100"])[0])
|
||||
return {"total": sum(c["videos"] for c in self.channels),
|
||||
"data": self.all_videos(start, count)}
|
||||
# ---- the routes the list screens need (mirrors FakePeertube.kt) ----
|
||||
if path == "/api/v1/config":
|
||||
return {"instance": {"name": self.spec.get("instanceName", "JTube Test")},
|
||||
"search": {"searchIndex": {"enabled": True},
|
||||
"remoteUri": {"users": True, "anonymous": False}}}
|
||||
if path == "/api/v1/users/me/videos":
|
||||
start = int(query.get("start", ["0"])[0])
|
||||
count = int(query.get("count", ["100"])[0])
|
||||
own = []
|
||||
for c in self.channels:
|
||||
if c.get("owner", self.owner["name"]) == self.owner["name"]:
|
||||
own.extend(self.videos_for(c["name"], 0, c["videos"]))
|
||||
return {"total": len(own), "data": own[start:start + count]}
|
||||
if path == "/api/v1/users/me/subscriptions/videos":
|
||||
start = int(query.get("start", ["0"])[0])
|
||||
count = int(query.get("count", ["100"])[0])
|
||||
feed = []
|
||||
for name in ("travels", "friends"):
|
||||
feed.extend(self.videos_for(name, 0, next(
|
||||
(c["videos"] for c in self.channels if c["name"] == name), 0)))
|
||||
return {"total": len(feed), "data": feed[start:start + count]}
|
||||
if path == "/api/v1/users/me/history/videos":
|
||||
start = int(query.get("start", ["0"])[0])
|
||||
count = int(query.get("count", ["100"])[0])
|
||||
watched = []
|
||||
for name in ("chronicles", "travels", "friends", "shorts"):
|
||||
watched.extend(self.videos_for(name, 0, min(6, next(
|
||||
(c["videos"] for c in self.channels if c["name"] == name), 0))))
|
||||
return {"total": len(watched), "data": watched[start:start + count]}
|
||||
if path == "/api/v1/search/videos":
|
||||
start = int(query.get("start", ["0"])[0])
|
||||
count = int(query.get("count", ["100"])[0])
|
||||
return {"total": sum(c["videos"] for c in self.channels),
|
||||
"data": self.all_videos(start, count)}
|
||||
if path == "/api/v1/search/video-channels":
|
||||
return {"total": len(self.channels), "data": [self.channel(c) for c in self.channels]}
|
||||
m = re.match(r"^/api/v1/accounts/([^/]+)$", path)
|
||||
if m:
|
||||
who = m.group(1)
|
||||
return {"name": who,
|
||||
"displayName": who if who != self.owner["name"] else self.owner["displayName"],
|
||||
"followersCount": 7,
|
||||
"avatars": [{"width": 120, "height": 120, "path": f"/lazy-static/avatars/{who}.jpg"}]}
|
||||
m = re.match(r"^/api/v1/videos/([A-Za-z0-9]+)$", path)
|
||||
if m:
|
||||
short = m.group(1)
|
||||
channel = next((c["name"] for c in self.channels if short.startswith(c["name"])), "chronicles")
|
||||
index = int(re.sub(r"\D", "", short) or 0)
|
||||
detail = self.video(channel, index)
|
||||
detail.update({
|
||||
"duration": 600 + index,
|
||||
"description": ("A long description for the info panel, with a link to "
|
||||
"https://joinpeertube.org/ and a second one at "
|
||||
"https://git.jeena.net/jeena/jtube-tv that OK can open."),
|
||||
"likes": 12, "dislikes": 0,
|
||||
"files": [{"id": 1, "fileUrl": self.base_url + "/lazy-static/videos/demo.mp4",
|
||||
"resolution": {"id": 1, "label": "720p"}, "mimeType": "video/mp4"}],
|
||||
"userHistory": {"currentTime": 60 + index},
|
||||
})
|
||||
return detail
|
||||
if path.startswith("/api/v1/users/me/subscriptions/exist"):
|
||||
return {}
|
||||
if path.startswith("/api/v1/users/me/subscriptions") and method in ("POST", "DELETE"):
|
||||
return {}
|
||||
if re.match(r"^/api/v1/videos/[^/]+/watching$", path) and method == "POST":
|
||||
return {}
|
||||
if path == "/api/v1/users/me/video-playlists":
|
||||
return {"total": len(self.spec.get("playlists", [])),
|
||||
"data": self.spec.get("playlists", [])}
|
||||
|
|
@ -131,6 +316,24 @@ def make_handler(fake: FakePeertube):
|
|||
|
||||
def _handle(self, method):
|
||||
parsed = urlparse(self.path)
|
||||
image = fake.image(parsed.path) if method == "GET" else None
|
||||
if image is None and method == "GET":
|
||||
clip = fake.media(parsed.path)
|
||||
if clip is not None:
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "video/mp4")
|
||||
self.send_header("Content-Length", str(len(clip)))
|
||||
self.send_header("Accept-Ranges", "bytes")
|
||||
self.end_headers()
|
||||
self.wfile.write(clip)
|
||||
return
|
||||
if image is not None:
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "image/jpeg")
|
||||
self.send_header("Content-Length", str(len(image)))
|
||||
self.end_headers()
|
||||
self.wfile.write(image)
|
||||
return
|
||||
body = fake.respond(method, parsed.path, parse_qs(parsed.query))
|
||||
if body is None:
|
||||
payload = json.dumps({"error": f"fake: no route for {parsed.path}"}).encode()
|
||||
|
|
|
|||