diff --git a/classes/video.py b/classes/video.py index afb5518..ac8613d 100644 --- a/classes/video.py +++ b/classes/video.py @@ -60,8 +60,8 @@ class Video: "title": self.idea['title'], "description": self.idea['description'] + "\n\n" + credits, } - if input("Do you want to generate a thumbnail ? (y/N) : ").lower() == "y": - await generate_thumbnail( self.path, self.idea['title'], self.idea['description']) + #if input("Do you want to generate a thumbnail ? (y/N) : ").lower() == "y": + await generate_thumbnail( self.path, self.idea['title'], self.idea['description']) videoid = await upload_video( self.path, self.idea['title'], self.metadata['description'], 28, "", "private", self.parent.path) printm(f"Your video is ready! You can find it in { self.path}") video_meta_file = { @@ -71,6 +71,8 @@ class Video: "path": self.path, "url": f"https://www.youtube.com/watch?v={videoid}", } + self.url = video_meta_file['url'] + self.id = videoid with open(os.path.join( self.path, "video.yaml"), "w") as f: yaml.dump(video_meta_file, f) f.close() diff --git a/generators/montage.py b/generators/montage.py index 02ddd7d..3547e72 100644 --- a/generators/montage.py +++ b/generators/montage.py @@ -15,7 +15,7 @@ from utils.wiki_downloader import download_image as wiki_download_image unsplash_access = getenv("unsplash_access_key") if not unsplash_access: raise Exception("UNSPLASH_ACCESS_KEY is not set in .env file") -unsplash_url = "https://api.unsplash.com/photos/random/?client_id=" + unsplash_access + "&query=" +unsplash_url = "https://source.unsplash.com/random/?" async def prepare(path): with open(os.path.join(path, "script.json"), 'r', encoding='utf-8') as f: @@ -42,12 +42,13 @@ async def prepare(path): if not os.path.exists(path + "/slides/assets"): os.mkdir(path + "/slides/assets") url= unsplash_url + script[i]['image'].replace("+", ",") - r = requests.get(url) - real_url = r.json()['urls']['raw'] + #r = requests.get(url) + #real_url = r.json()['urls']['raw'] + real_url = url with open(path + "/slides/assets/slide" + str(i) + ".jpg", 'wb') as f: - f.write(requests.get(real_url).content) + f.write(requests.get(real_url, allow_redirects=True).content) f.close() - content = marp + f"\n\n" + content = marp.replace("[imagesrc]", "assets/slide" + str(i) + ".jpg") with open(path + "/slides/slide" + str(i) + ".md", 'w', encoding='utf-8') as f: f.write(content) elif "wikimage" in script[i]: @@ -62,7 +63,10 @@ async def prepare(path): print("Trying to download image for slide " + str(i)) wiki_download_image(script[i]['wikimage'], os.path.abspath(os.path.join(path, "slides", "assets", "slide" + str(i) + ".jpg"))) print("Downloaded image for slide with wikiimage " + str(i)) - break + if not os.path.exists(os.path.join(path, "slides", "assets", "slide" + str(i) + ".jpg")): + raise FileNotFoundError + else: + break except: r += 1 if r > 5: diff --git a/prompts/marp.md b/prompts/marp.md index 7df607d..4f3c028 100644 --- a/prompts/marp.md +++ b/prompts/marp.md @@ -5,4 +5,29 @@ class: - lead - invert backgroundImage: url(https://images.unsplash.com/photo-1651604454911-fdfb0edde727) ---- \ No newline at end of file +--- + + +