Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/support-undownloadable-vimeo-links #205

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions cdp_backend/tests/conftest.py
Expand Up @@ -40,6 +40,9 @@ def resources_dir() -> Path:
# City of Versailles, Kentucky
EXAMPLE_VIMEO = "https://vimeo.com/503166067"

# City of Chicago, Illinois
EXAMPLE_VIMEO_SHOWCASE = "https://vimeo.com/showcase/6277394/video/722690793"


@pytest.fixture
def example_video(resources_dir: Path) -> Path:
Expand Down
Binary file modified cdp_backend/tests/resources/example_video.mp4
Binary file not shown.
2 changes: 2 additions & 0 deletions cdp_backend/tests/utils/test_file_utils.py
Expand Up @@ -26,6 +26,7 @@
EXAMPLE_VIDEO_FILENAME,
EXAMPLE_VIDEO_HD_FILENAME,
EXAMPLE_VIMEO,
EXAMPLE_VIMEO_SHOWCASE,
EXAMPLE_YOUTUBE_VIDEO_EMBEDDED,
EXAMPLE_YOUTUBE_VIDEO_PARAMETER,
EXAMPLE_YOUTUBE_VIDEO_SHORT,
Expand Down Expand Up @@ -247,6 +248,7 @@ def test_convert_video_to_mp4(
(EXAMPLE_YOUTUBE_VIDEO_PARAMETER, "XALBGkjkUPQ.mp4"),
(EXAMPLE_YOUTUBE_VIDEO_SHORT, "XALBGkjkUPQ.mp4"),
(EXAMPLE_VIMEO, Path("503166067") / "503166067.mp4"),
(EXAMPLE_VIMEO_SHOWCASE, Path("722690793") / "722690793.mp4"),
(EXAMPLE_M3U8_PLAYLIST_URI, None),
],
)
Expand Down
7 changes: 6 additions & 1 deletion cdp_backend/utils/file_utils.py
Expand Up @@ -4,6 +4,7 @@
import logging
import math
import random
import re
from hashlib import sha256
from pathlib import Path
from typing import Optional, Tuple, Union
Expand Down Expand Up @@ -226,7 +227,11 @@ def vimeo_copy(uri: str, dst: Path, overwrite: bool = False) -> str:
if dst.is_file() and not overwrite:
raise FileExistsError(dst)

v = Vimeo(uri)
# 9 is the length of the video id; no other
# string of numbers in the URL has length 9 (thankfully)
match = re.findall(r"\d{9}", uri)
vid = match[0]
sagarrat7 marked this conversation as resolved.
Show resolved Hide resolved
v = Vimeo.from_video_id(video_id=vid)

if len(v.streams) == 0:
raise ValueError("File {} contains no downloadable streams", uri)
Expand Down