mirror of
https://github.com/bellingcat/vk-url-scraper.git
synced 2026-06-09 20:08:35 +03:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42bdc1441c | ||
|
|
c25880ee6d | ||
|
|
e1e3648852 | ||
|
|
c74dc280d8 |
@@ -135,4 +135,8 @@ def test_scrape_video_only2():
|
||||
with tempfile.TemporaryDirectory(dir="./") as tempdir:
|
||||
vks.download_media(res, tempdir)
|
||||
found_files = set(os.listdir(tempdir))
|
||||
assert "video-17546758_456239898_0.mkv.webm" in found_files
|
||||
# different systems might attribute different extension
|
||||
assert (
|
||||
"video-17546758_456239898_0.webm" in found_files
|
||||
or "video-17546758_456239898_0.mp4" in found_files
|
||||
)
|
||||
|
||||
@@ -312,7 +312,7 @@ class VkScraper:
|
||||
downloaded.append(filename)
|
||||
elif k == "video":
|
||||
for i, url in enumerate(attachments):
|
||||
filename = os.path.join(destination, f"{r['id']}_{i}.mkv")
|
||||
filename = os.path.join(destination, f"{r['id']}_{i}.%(ext)s")
|
||||
ydl = yt_dlp.YoutubeDL(
|
||||
{
|
||||
"outtmpl": filename,
|
||||
@@ -323,5 +323,11 @@ class VkScraper:
|
||||
)
|
||||
info = ydl.extract_info(url, download=True)
|
||||
filename = ydl.prepare_filename(info)
|
||||
if "unknown_video" in filename:
|
||||
new_filename = filename.replace("unknown_video", "mkv")
|
||||
with open(filename, "rb") as vin, open(new_filename, "wb") as vout:
|
||||
vout.write(vin.read())
|
||||
os.remove(filename)
|
||||
filename = new_filename
|
||||
downloaded.append(filename)
|
||||
return downloaded
|
||||
|
||||
@@ -2,7 +2,7 @@ _MAJOR = "0"
|
||||
_MINOR = "2"
|
||||
# On main and in a nightly release the patch should be one ahead of the last
|
||||
# released build.
|
||||
_PATCH = "2"
|
||||
_PATCH = "3"
|
||||
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
||||
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
||||
_SUFFIX = ""
|
||||
|
||||
Reference in New Issue
Block a user