{"id":355131,"date":"2024-05-20T23:02:23","date_gmt":"2024-05-20T23:02:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355131"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355131","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0435\u0437\u0430\u0442\u044c \u0438 \u0437\u0430\u043b\u0438\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u043d\u0430 \u042f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a \u2014 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/qt\/sj\/yj\/qtsjyjtgqwvjxl3ugifv6vcn7do.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/qt\/sj\/yj\/qtsjyjtgqwvjxl3ugifv6vcn7do.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 python, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u0430 \u00ab\u042f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a\u0430\u00bb \u043d\u0430\u0440\u0435\u0437\u0430\u0442\u044c \u0438 \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u0444\u0430\u0439\u043b\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0442 1 \u0413\u0431 (\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0440\u0438\u0444\u0430), \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e api \u00abyandex.\u0434\u0438\u0441\u043a\u0430\u00bb \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e python.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435<\/h2>\n<p>  \u041f\u043e\u0433\u0440\u0443\u0437\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u043c\u0438\u043c\u043e \u043c\u0435\u043d\u044f \u043a\u0430\u043a-\u0442\u043e \u043c\u0438\u043c\u043e \u043f\u0440\u043e\u0448\u043b\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043b\u043e\u0436\u0435\u043d\u0430 \u043c\u0438\u0441\u0441\u0438\u044f \u043f\u043e \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0443 \u0432\u0438\u0434\u0435\u043e\u0444\u0430\u0439\u043b\u043e\u0432<a href=\"https:\/\/habr.com\/ru\/news\/676098\/\"> \u0441\u0442\u0430\u043b \u043f\u043b\u0430\u0442\u043d\u044b\u043c<\/a>. \u0420\u0435\u0447\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e \u00ab\u042f\u043d\u0434\u0435\u043a\u0441. \u0434\u0438\u0441\u043a\u0435\u00bb.<\/p>\n<p>  \u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u00ab\u0441\u0442\u0430\u0440\u044b\u0445\u00bb \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u0431\u044b\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u043e\u0441\u043b\u0430\u0431\u043b\u0435\u043d\u0438\u044f \u2014 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043b\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u043e \u0433\u0430\u0431\u0430\u0440\u0438\u0442\u0430\u043c \u043f\u043e\u043c\u0435\u0449\u0430\u043b\u0441\u044f \u0432 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u043d\u0430 \u043e\u0431\u043b\u0430\u043a\u0435. \u041d\u043e \u043f\u043e\u0442\u043e\u043c \u0438 \u044d\u0442\u0443 \u00ab\u043b\u0430\u0432\u043e\u0447\u043a\u0443 \u043f\u0440\u0438\u043a\u0440\u044b\u043b\u0438\u00bb \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 1\u0413\u0431.<\/p>\n<p>  \u0412 \u0432\u043e\u0437\u0434\u0443\u0445\u0435 \u043f\u043e\u0432\u0438\u0441\u043b\u0430 \u043f\u0430\u0443\u0437\u0430 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043b\u0438\u0431\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0440\u0435\u0441\u0443\u0440\u0441. <\/p>\n<p>  \u041d\u043e, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u00ab\u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u0440\u0443\u0433 \u043b\u0443\u0447\u0448\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0432\u0443\u0445\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 api \u00ab\u044f\u043d\u0434\u0435\u043a\u0441. \u0434\u0438\u0441\u043a\u0430\u00bb, \u0430, \u0437\u0430\u043e\u0434\u043d\u043e, \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 splitter \u0432\u0438\u0434\u0435\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0446\u0435\u043b\u044b\u0445 199 \u0440. \u0432 \u043c\u0435\u0441\u044f\u0446 \u043d\u0430 \u00ab\u0441\u0442\u0430\u0440\u043e\u043c \u0434\u0440\u0443\u0433\u0435\u00bb.<\/p>\n<h2>\u041a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0430\u0440\u0435\u0437\u043a\u0438 \u0432\u0438\u0434\u0435\u043e<\/h2>\n<p>  \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0441\u0442\u0430: \u0434\u0440\u043e\u0431\u0438\u043c \u0432\u0438\u0434\u0435\u043e \u043f\u043e 1\u0413\u0431, \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430 \u00ab\u044f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a\u00bb (\u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443 \u2014 \u00ab\u042f\u00bb), \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438 (\u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0432 txt.<\/p>\n<p>  \u0412 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u043c\u0443 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043d\u0438\u044e \u0432\u0438\u0434\u0435\u043e \u043d\u0430\u0433\u0438\u0442\u0445\u0430\u0431\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435 \u043e\u043d\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438, \u0430 \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u2014 \u0431\u044b\u0441\u0442\u0440\u044b\u043c\u0438 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435, \u0441\u0430\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 (\u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0435 split.py), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f ffmpeg:<\/p>\n<pre><code class=\"python\">import subprocess,os  class Split:     def __init__(self,maxSize,path):         '''Size of the chunks in MB and path to save the pieces'''         self.maxSize = int((maxSize-10) * 1024)         self.path = path     def splitVid(self,file):         '''File to split'''         video_size = os.path.getsize(file)         video_size = video_size \/ 1024         video_duration = subprocess.run([\"ffprobe\", \"-v\", \"error\", \"-show_entries\", \"format=duration\", \"-of\", \"default=noprint_wrappers=1:nokey=1\", file], stdout=subprocess.PIPE).stdout.decode('utf-8')         pieces_duration = round(float(video_duration) \/ (int(video_size \/ self.maxSize) + 1))         subprocess.run([\"ffmpeg\", \"-i\", file, \"-c\", \"copy\", \"-f\", \"segment\", \"-segment_time\", str(pieces_duration), \"-loglevel\", \"quiet\", \"-reset_timestamps\", \"1\", f\"{self.path}part%02d_vid.mp4\"])<\/code><\/pre>\n<p>  \u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 (example.py):<\/p>\n<pre><code class=\"python\">from split import Split  splitter = Split(1000,\".\/\") splitter.splitVid(\"video.mkv\")<\/code><\/pre>\n<p>  \u0433\u0434\u0435 1000 \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 \u041c\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u0430 video.mkv \u2014 \u0432\u0438\u0434\u0435\u043e \u0434\u043b\u044f \u043d\u0430\u0440\u0435\u0437\u043a\u0438.<\/p>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u0432 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u0440\u0435\u0437\u043a\u0438 \u0432\u0438\u0434\u0435\u043e. \u041d\u043e, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0441 \u042f \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<h2>\u041e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 api \u00ab\u044f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a\u0430\u00bb<\/h2>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0442\u043e\u043a\u0435\u043d, \u0431\u043b\u0430\u0433\u043e \u043e\u043d \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439.<br \/>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u043e\u0439\u0434\u044f \u0440\u044f\u0434 \u0448\u0430\u0433\u043e\u0432, \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u00ab\u044f\u043d\u0434\u0435\u043a\u0441\u0435\u00bb. \u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435.<\/p>\n<p>  \u0412 \u043e\u0441\u043d\u043e\u0432\u0443 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0437 <a href=\"https:\/\/github.com\/ivknv\/yadisk\" rel=\"nofollow noopener noreferrer\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u2014 yadisk<\/a>.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u2014 <\/p>\n<pre><code class=\"python\">pip install yadisk<\/code><\/pre>\n<p>  \u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0435\u0435 async \u0441\u0435\u0441\u0442\u0440\u0430 \u2014 <a href=\"https:\/\/github.com\/ivknv\/yadisk-async\" rel=\"nofollow noopener noreferrer\">yadisk-async<\/a>.<\/p>\n<p>  \u0421 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u0438 \u0441 \u042f \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u0441\u0435 \u0431\u0435\u0437\u043e\u0431\u043b\u0430\u0447\u043d\u043e, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0437\u044f\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 (\u0432\u0438\u0434\u0435\u043e\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430) async \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0412 \u0440\u0435\u043f\u043e yadisk \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u042f \u043f\u043e api.<\/p>\n<p>  \u041c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0438\u0441\u043a\u0435.<\/p>\n<pre><code class=\"python\"> import posixpath import os import yadisk #windows version from time import sleep  y = yadisk.YaDisk(token=\"\u0442\u043e\u043a\u0435\u043d\")  # \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \"\/test-dir\" print(y.mkdir(\"\/test-dir\")) to_dir = \"\/test-dir\" from_dir = \"to_upload\"  #\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 #print(y.get_disk_info().FIELDS) fields=y.get_disk_info().FIELDS free_space=(fields['total_space']-fields['used_space'])\/1048576 trash=fields['trash_size']\/1048576 print(f\"\u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0430 yandex disk: {round(free_space,2)} \u041c\u0431\", ) print(f\"\u043a\u043e\u0440\u0437\u0438\u043d\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442: {round(trash,2)} \u041c\u0431\", )  def recursive_upload(y, from_dir, to_dir):     for root, dirs, files in os.walk(from_dir):         p = root.split(from_dir)[1].strip(os.path.sep)         dir_path = posixpath.join(to_dir, p)         #print(dir_path)     #try:         #y.mkdir(dir_path)     #except yadisk.exceptions.PathExistsError as e:         #print(e)         #pass          for file in files:              file_path = posixpath.join(dir_path, file)              #print(file_path)              #p_sys = p.replace(\"\/\", os.path.sep)                           in_path = os.path.join(from_dir, file)              print(in_path)              try:                  y.upload(in_path, file_path)              except yadisk.exceptions.PathExistsError as e:                  print(e)                  #pass  recursive_upload(y, from_dir, to_dir) print(\"\u0437\u0430\u043b\u0438\u0442\u043e\") #print(list(y.listdir(\"\/test-dir\")))  for f in list(y.listdir(to_dir)):     y.publish(f'{to_dir}\/{f.FIELDS[\"file\"].split(\"&amp;\")[1].split(\"=\")[1]}') # make file public  with open (\"links.txt\", \"a\") as l:     for f in list(y.listdir(\"\/test-dir\")):         print(f.FIELDS[\"public_url\"]) #public url         l.write(f.FIELDS[\"public_url\"]+'\\n')                  print('\u0433\u043e\u0442\u043e\u0432\u043e') <\/code><\/pre>\n<p>   \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f os windows. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u043e\u0434.<\/p>\n<p>  \u0418\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 to_upload \u0437\u0430\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0443 test-dir \u043d\u0430 \u042f \u0432\u0441\u0435 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0435 \u0432\u0438\u0434\u0435\u043e\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0430 yandex disk \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u0440\u0437\u0438\u043d\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u043e\u043c\u0443 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u043f\u0435\u0445\u0430, \u0430 \u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <\/p>\n<pre><code class=\"python\"> y.publish(f'{to_dir}\/{f.FIELDS[\"file\"].split(\"&amp;\")[1].split(\"=\")[1]}') # make file public<\/code><\/pre>\n<p>  \u0444\u0430\u0439\u043b\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f. *\u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. <\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0432\u0441\u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b links.txt.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u0442\u044b \u0432 mp4, \u043d\u043e \u0438 \u043b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>  \u0418 \u0442\u0443\u0442 \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043d\u044e\u0430\u043d\u0441\u0430\u0445.<\/p>\n<h2>\u041d\u044e\u0430\u043d\u0441\u044b api \u00ab\u044f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a\u0430\u00bb<\/h2>\n<p>  \u041a\u0430\u043a \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u0435\u0441\u043b\u0438 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u2014 mp4, db \u0438 \u0442.\u0434. \u2014 \u0434\u0435\u043b\u043e \u043d\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0435. \u041f\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043e\u043d\u0438 \u043b\u0438\u0431\u043e \u043d\u0435 \u0437\u0430\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u043e\u0432\u0441\u0435 \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u0438\u0439.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/yadisk-async.readthedocs.io\/ru\/latest\/known_issues.html\" rel=\"nofollow noopener noreferrer\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  \u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0441\u043b\u043e\u0436\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u2014 \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0443\u0434\u0430\u043b\u0438\u0432 \u0443 \u043d\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u00abvideo.mp4\u00bb, \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u00abvideo\u00bb.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439:<\/p>\n<pre><code class=\"python\">os.rename(f'{from_dir}\/{file}',f'{from_dir}\/{file.split(\".\")[0]}') <\/code><\/pre>\n<p>  \u0411\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"python\">for file in files:                         os.rename(f'{from_dir}\/{file}',f'{from_dir}\/{file.split(\".\")[0]}')                         file_path = posixpath.join(dir_path, file)<\/code><\/pre>\n<h2>\u0420\u0435\u043c\u0430\u0440\u043a\u0430 \u043f\u043e async \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441 \u042f \u043d\u0435 \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e async \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0442 \u0432\u044b\u043b\u0435\u0442\u0430. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0437\u0430\u043b\u0438\u0432\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0438\u0437-\u0437\u0430 timeout \u2014 <a href=\"https:\/\/github.com\/ivknv\/yadisk-async\/issues\/5\" rel=\"nofollow noopener noreferrer\">issue<\/a>.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 async \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432 timeout.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434 (\u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0445) \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\"> async def main():     print(\"token valid: \",await y.check_token())     print(\"\u0437\u0430\u043b\u0438\u0432\u0430\u044e...\")              async with aiofiles.open(\"ghosted_1\", \"rb\") as f:         await y.upload(f, \"\/test-dir\/ghosted_1\",timeout=100)     print(\"\u0437\u0430\u043b\u0438\u043b\")       if __name__ == '__main__':   loop = asyncio.get_event_loop()   loop.run_until_complete(main())   loop.close()<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>  \u041e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430\u0437\u0430\u0434, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0441\u0442\u043e\u044f\u0442 \u043b\u0438 199 \u0440. \u0442\u0430\u043a\u0438\u0445 \u0442\u0440\u0443\u0434\u043e\u0432? \u0412\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0432\u0435\u0434\u044c \u0437\u0430\u043b\u0438\u0442\u044b\u0435 \u0432\u0438\u0434\u0435\u043e\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u043e 1\u0413\u0431 \u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u042f \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043d\u0430 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435. \u0417\u0434\u0435\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0430\u0432\u0442\u043e\u0440.<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/761652\/\"> https:\/\/habr.com\/ru\/articles\/761652\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/qt\/sj\/yj\/qtsjyjtgqwvjxl3ugifv6vcn7do.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/qt\/sj\/yj\/qtsjyjtgqwvjxl3ugifv6vcn7do.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 python, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u0430 \u00ab\u042f\u043d\u0434\u0435\u043a\u0441.\u0434\u0438\u0441\u043a\u0430\u00bb \u043d\u0430\u0440\u0435\u0437\u0430\u0442\u044c \u0438 \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u0444\u0430\u0439\u043b\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0442 1 \u0413\u0431 (\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0440\u0438\u0444\u0430), \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e api \u00abyandex.\u0434\u0438\u0441\u043a\u0430\u00bb \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e python.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-355131","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355131"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355131\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}