feat: update Vimeo embed URLs to hide branding and titles for improved user experience
Browse files- app/main.py +4 -1
- tests/test_scoring.py +2 -2
app/main.py
CHANGED
|
@@ -159,7 +159,10 @@ def video_embed(url: str) -> str:
|
|
| 159 |
if url.startswith(YOUTUBE_KEPT): # without cookies until the video is played, and with no other channels' videos at its end
|
| 160 |
return f"https://www.youtube-nocookie.com/embed/{url.removeprefix(YOUTUBE_KEPT)}?rel=0"
|
| 161 |
number, _, h = url.removeprefix("https://vimeo.com/").partition("/")
|
| 162 |
-
return f"https://player.vimeo.com/video/{number}?" + urllib.parse.urlencode({
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
def class_members(text: str) -> tuple[list[str], dict[str, str]]:
|
|
|
|
| 159 |
if url.startswith(YOUTUBE_KEPT): # without cookies until the video is played, and with no other channels' videos at its end
|
| 160 |
return f"https://www.youtube-nocookie.com/embed/{url.removeprefix(YOUTUBE_KEPT)}?rel=0"
|
| 161 |
number, _, h = url.removeprefix("https://vimeo.com/").partition("/")
|
| 162 |
+
return f"https://player.vimeo.com/video/{number}?" + urllib.parse.urlencode({
|
| 163 |
+
**({"h": h} if h else {}), "dnt": 1,
|
| 164 |
+
"vimeo_logo": 0, "title": 0, "byline": 0, "portrait": 0,
|
| 165 |
+
})
|
| 166 |
|
| 167 |
|
| 168 |
def class_members(text: str) -> tuple[list[str], dict[str, str]]:
|
tests/test_scoring.py
CHANGED
|
@@ -570,8 +570,8 @@ def test_sign_in_guards_the_practice_endpoints():
|
|
| 570 |
first, second = c.get("/api/videos", headers=good).json()["videos"]
|
| 571 |
N1 = sum(k["lesson"] == READY[0] for k in CATEGORIES) # a new video stands after its lesson's topics
|
| 572 |
assert first == {"id": 1, "lesson": READY[0], "title": "驻转讬讞讛 诇砖讬注讜专", "url": "https://vimeo.com/1233611297/d46ac373c8",
|
| 573 |
-
"embed": "https://player.vimeo.com/video/1233611297?h=d46ac373c8&dnt=1", "pos": N1, "ord": 1}
|
| 574 |
-
assert (second["url"], second["embed"]) == ("https://vimeo.com/76979871", "https://player.vimeo.com/video/76979871?dnt=1")
|
| 575 |
from app.main import vimeo_link, video_embed, video_link
|
| 576 |
assert vimeo_link("https://player.vimeo.com/video/1233611297?h=d46ac373c8") == first["url"]
|
| 577 |
# a YouTube link, in any of its forms, is kept as the watch link and played without cookies
|
|
|
|
| 570 |
first, second = c.get("/api/videos", headers=good).json()["videos"]
|
| 571 |
N1 = sum(k["lesson"] == READY[0] for k in CATEGORIES) # a new video stands after its lesson's topics
|
| 572 |
assert first == {"id": 1, "lesson": READY[0], "title": "驻转讬讞讛 诇砖讬注讜专", "url": "https://vimeo.com/1233611297/d46ac373c8",
|
| 573 |
+
"embed": "https://player.vimeo.com/video/1233611297?h=d46ac373c8&dnt=1&vimeo_logo=0&title=0&byline=0&portrait=0", "pos": N1, "ord": 1}
|
| 574 |
+
assert (second["url"], second["embed"]) == ("https://vimeo.com/76979871", "https://player.vimeo.com/video/76979871?dnt=1&vimeo_logo=0&title=0&byline=0&portrait=0")
|
| 575 |
from app.main import vimeo_link, video_embed, video_link
|
| 576 |
assert vimeo_link("https://player.vimeo.com/video/1233611297?h=d46ac373c8") == first["url"]
|
| 577 |
# a YouTube link, in any of its forms, is kept as the watch link and played without cookies
|