Compare commits

...

7 Commits

Author SHA1 Message Date
Miguel Ramalho
42bdc1441c Bump version to v0.2.3 for release 2022-06-21 01:23:29 +02:00
msramalho
c25880ee6d fix tests 2022-06-21 01:21:53 +02:00
msramalho
e1e3648852 remove print 2022-06-21 01:17:47 +02:00
msramalho
c74dc280d8 fix ytdlp naming 2022-06-21 01:17:26 +02:00
Miguel Ramalho
ab15b35008 Bump version to v0.2.2 for release 2022-06-21 01:04:24 +02:00
msramalho
62c4536d0b fix ytdl filenames 2022-06-21 01:03:48 +02:00
Miguel Ramalho
eac0fc4904 Bump version to v0.2.1 for release 2022-06-20 23:57:04 +02:00
3 changed files with 27 additions and 6 deletions

View File

@@ -131,5 +131,12 @@ def test_scrape_video_only():
def test_scrape_video_only2():
res = vks.scrape("https://vk.com/video-1_456239018")
print(res[0]["attachments"]["video"][0])
res = vks.scrape("https://vk.com/video-17546758_456239898")
with tempfile.TemporaryDirectory(dir="./") as tempdir:
vks.download_media(res, tempdir)
found_files = set(os.listdir(tempdir))
# different systems might attribute different extension
assert (
"video-17546758_456239898_0.webm" in found_files
or "video-17546758_456239898_0.mp4" in found_files
)

View File

@@ -312,8 +312,22 @@ class VkScraper:
downloaded.append(filename)
elif k == "video":
for i, url in enumerate(attachments):
filename = os.path.join(destination, f"{r['id']}_{i}.mkv")
ydl = yt_dlp.YoutubeDL({"outtmpl": filename, "quiet": True})
ydl.extract_info(url, download=True)
filename = os.path.join(destination, f"{r['id']}_{i}.%(ext)s")
ydl = yt_dlp.YoutubeDL(
{
"outtmpl": filename,
"quiet": True,
"restrictfilenames": True,
"forcefilename": True,
}
)
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

View File

@@ -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 = "0"
_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 = ""