Почему здесь проблема с путем?
Код:
from pytube import YouTube
import os, random, shutil, zipfile
class DownloadbyURL:
def __init__(self, link):
self.link = link
self.path = 'Videos'
def downloadYouTube(self):
yt = YouTube(self.link)
yt_stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if not os.path.exists(self.path):
os.makedirs(self.path)
yt_stream.download(self.path)
return yt_stream.default_filename, yt_stream.title, yt.description, ', '.join(yt.keywords)
class Download:
def __init__(self, link):
id = str(random.randint(1111111,9999999))
path = 'Archives\\' + id
path_zip = path + '.zip'
result = DownloadbyURL(link)
result = result.downloadYouTube()
title = result[1]
desc = result[2]
tags = result[3]
if not os.path.exists(path):
os.makedirs(path)
open(path + '\\Title.txt', 'w', encoding='utf-8').write(title)
open(path + '\\Description.txt', 'w', encoding='utf-8').write(desc)
open(path + '\\Tags.txt', 'w', encoding='utf-8').write(tags)
open(path + '\\Info.txt', 'w', encoding='utf-8').write(f'URL: {link}\n\nTitle: {title}\nDescription: {desc}\nTags: {tags}')
shutil.copyfile('root/moibot/Videos/' + result[0], path + '\\' + result[0])
zipp = zipfile.ZipFile(path_zip, 'w')
ls = os.listdir(path)
blacklist = []
for file in ls:
for dirpath, dirs, files in os.walk(path):
for f in files:
if f not in blacklist:
fn = os.path.join(dirpath, f)
zipp.write(fn)
blacklist.append(f)
shutil.rmtree(path)
self.file = 'root/moibot/Videos/' + result[0]
self.path_zip = path_zip
Выдает ошибку:
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'root/moibot/Videos/Видеокарта с водяным охлаждением.mp4