def download(url, path): """单独下载""" sys.argv = ['you-get', '-o', path, url] try: you_get.main() except: print("错误:" + url)
def downloads(url, path): """列表下载""" sys.argv = ['you-get', '--playlist', '-o', path, url] try: you_get.main() except: print("错误:" + url)
def download(self): path = 'D:\\test' checkdict = TestMongo().read_line() for item in checkdict: # 正则表达是判定是否为合法链接 # url = self.url.get() url = item["url"] #path = self.path.get() if re.match(r'^https?:/{2}\w.+$', url): if path != '': msgbox.showwarning(title='警告', message='下载过程中窗口如果出现短暂卡顿说明文件正在下载中!') try: sys.argv = ['you-get', '-o', path, url] you_get.main() except Exception as e: print(e) msgbox.showerror(title='error', message=e) msgbox.showinfo(title='info', message='下载完成!') else: msgbox.showerror(title='error', message='输出地址错误!') else: msgbox.showerror(title='error', message='视频地址错误!')
def download_video(self,url,av): directory = self.base_config['video_local_dir'] print(directory) sys.argv = ['you-get','--format=flv360','--no-caption','-o', directory,'-O',str(av),url] # sys.argv = ['you-get', '-i', url] you_get.main() pass
def downLoadVideo(video_url, video_path, result_queue): os_getpid = os.getpid() # video_url = 'http://s1.meetsocial.cn/' + str(url) video_name = ''.join(video_url.split('/')[-1:]) # video_name = str(os_getpid) file_path = video_path + '/' + video_name absolute_path = path.abspath(path.join(path.dirname(__file__), file_path)) logging.info(video_path) # # request.urlretrieve(video_url, path) try: if not os.path.isfile(absolute_path): sys.argv = ['you-get', '-o', video_path, '-O', video_name[:video_name.rfind('.')], video_url] you_get.main() except Exception as e: logging.info(str(e)) logging.info("Error in url: {0}".format(video_url)) totalFrameNumber, frameRate, img_size, phash = video_process(file_path) print(totalFrameNumber, frameRate, img_size, phash) video_dict = OrderedDict() value_list = [video_url, totalFrameNumber, frameRate, img_size, phash] param_list = ["video_path", "totalFrameNumber", "frameRate", "img_size", "phash"] for index, param in enumerate(param_list): video_dict[param] = None try: video_dict[param] = str(value_list[index]) except: pass logging.info(video_dict) result_queue.put(video_dict) try: os.remove(absolute_path) except: pass
def you_get_download(self, url, path, video_name): # *you-get下载方式 太慢 try: sys.argv = ['you-get', '-o', path, '-O', video_name+".mp4", url] you_get.main() except: print("you-get 下载失败")
def dowload_url(i): name = "Kaguya-sama wa Kokurasetai Tensai-tachi no Ren ai Zunousen [720P_10Bit_HEVC_FLAC][{}]".format( i) url = video_urls[i-1] print(name) print(url) sys.argv = ['you-get', '-o', r'./かぐや様は告らせたい~天才たちの恋愛頭脳戦~', '-O', name, url] you_get.main()
def download(self, url): sys.argv = ['you-get', '-o', self.path, url] you_get.main() # 下载完成,删除xml文件 for file in os.listdir(self.path): if file[-3:] == 'xml': self.common.rmfile(os.path.join(self.path, file))
def you_get_download(url, path): print("outputting you-get....") print(url) print(path) file_name = time.strftime("%Y%m%d-%H%M%S") + ".mp4" print(file_name) sys.argv = ['you-get', '-o', path, '-O', file_name, url] you_get.main() return file_name
def download(url): # 写法1 # cmd = 'you-get -o {} {}'.format(path, url) # print(cmd) # os.system(cmd) # 写法2 sys.argv = ['you-get', '-o', path, url] you_get.main() print("下载完成")
def video_download(self): # 正则表达是判定是否为合法链接 url = self.url.get() path = self.path.get() try: sys.argv = ['you-get', '-o', path, url] you_get.main() except Exception as e: print(e) logging.info()
def download(url): #下载type为视频清晰类型 import sys import getpass import you_get user = getpass.getuser() directory = r'/home/patinousward/下载/bilibili' print(url) print(directory) sys.argv = ['you-get', '--playlist', '-o', directory, url] you_get.main() print('finish download :', url)
def download_by_index(number): response = requests.get(URL % number) soup = BeautifulSoup(response.text, 'html.parser') title = soup.select_one('.vlesson-infoR > h1').text.replace(' ', '').replace( '-', '_') for lesson in soup.select('.lesson-lists > li > a'): url = 'http://www.maiziedu.com' + lesson.get('href') name = lesson.find(class_='fl').text.replace(' ', '').replace('-', '_') sys.argv = COMMAND.format(dir=title, name=name, url=url).split() you_get.main()
def video_download(self): # 正则表达是判定是否为合法链接 url = self.url.get() path = self.path.get() if re.match(r'^https?:/{2}\w.+$', url): if path != '': msgbox.showwarning(title='警告', message='下载过程中窗口如果出现短暂卡顿说明文件正在下载中!') try: sys.argv = ['you-get', '-o', path, url] you_get.main() except Exception as e: print(e) msgbox.showerror(title='error', message=e) msgbox.showinfo(title='info', message='下载完成!') else: msgbox.showerror(title='error', message='输出地址错误!') else: msgbox.showerror(title='error', message='视频地址错误!')
def download_upload(url): path = os.path.basename(url) # 视频输出的位置 name = unquote(path).split('.')[0] type = unquote(path).split('.')[-1] print(name, type) with closing(requests.get(url)) as response: if response.status_code == 200: try: # 下载 sys.argv = ['you-get', '-O', name, url] you_get.main() print("download Ok") # 上传 oss2.resumable_upload(bucket, path, path, multipart_threshold=100 * 1024) oss_path_url = "https://weixin-download.oss-cn-beijing.aliyuncs.com/" + quote( path) print("upload Ok", oss_path_url) # 删除本地文件 os.remove(path) print("remove OK") result = "OK" except Exception as e: result = "上传错误,请稍后再试" oss_path_url = "" else: result = "下载错误,请检查链接" oss_path_url = "" res = '[文件名]:%s\n[状态]:%s' % (path, result) if oss_path_url != "": res += '\n[下载地址]:%s' % (oss_path_url) return res
def video_download(self): url = self.url.get() path = self.path.get() if re.match(r'^https?:/{2}\w.+$', url): if path != '': msgbox.showwarning(title='警告', message='下载过程中窗口如果出现短暂卡顿说明文件正在下载中!') try: self.root.withdraw() sys.argv = ['you-get', '-o', path, url] you_get.main() except Exception as e: msgbox.showerror(title='警告', message=e) msgbox.showinfo(title='成功', message='下载完成!') self.root.wm_deiconify() else: msgbox.showerror(title='警告', message='输出地址错误!') self.root.wm_deiconify() else: msgbox.showerror(title='警告', message='视频地址错误!') self.root.wm_deiconify()
def you_get_download(url=None, path=None, rename=False): """ 调用you-get 抓取视频 :param url: 视频url :param path: 存储路径 :return: """ if "win" not in sys.platform: path = '/data/video' else: path = './files/video' if not os.path.exists(path): os.makedirs(path) assert isinstance(rename, bool) # 由于python 语言的特性,无法限制参数的类型,如果要限制类型需在代码中判断 if "http" in url: if rename: name = md5(url) sys.argv = ['you_get', '-o', path, '-O', name, url] else: sys.argv = ['you_get', '-o', path, url] you_get.main()
def download_bilibili_video_by_you_get(url, path, filename): """ you-get使用手册: 可选参数: -V, --version 查看版本并退出 -h, --help 查看帮助信息 不影响使用的选项: -i, --info 查看页面视频信息 -u, --url 查看页面视频信息包括解析的url地址 --json 以json格式查看页面视频信息 下载选项: -n, --no-merge 不合并视频 --no-caption 不下载字幕 -f, --force 强制覆盖现有文件 -F STREAM_ID, --format STREAM_ID 指定视频的格式 -O FILE, --output-filename FILE 指定下载的文件名称 -o DIR, --output-dir DIR 指定下载文件的目录 -p PLAYER, --player PLAYER 把视频流输出到指定的播放器 -c COOKIES_FILE, --cookies COOKIES_FILE 加载cookie文件 -t SECONDS, --timeout SECONDS 设置超时时间 -d, --debug 显示跟踪、调试信息 -I FILE, --input-file FILE 从文件读取url列表 -P PASSWORD, --password PASSWORD 指定加密视频的密码 -l, --playlist 显示可以下载的列表 -a, --auto-rename 自动重命名相同的名称不同的文件 代理选项: -x HOST:PORT, --http-proxy HOST:PORT 使用http代理下载 -y HOST:PORT, --extractor-proxy HOST:PORT 仅抓取数据时使用http代理 --no-proxy 关闭代理 -s HOST:PORT, --socks-proxy HOST:PORT 使用socks5代理进行下载 :param url: :param path: :param filename: :return: """ sys.argv = ['you-get', '-o', path, '-O', filename, url] you_get.main()
def download(path, url): '''下载''' sys.argv = ['you-get', '-o', path, url] you_get.main()
def download(url): sys.argv = ['you-get', '-i', url] you_get.main()
def download(url, path): sys.argv = ['you-get', '--playlist', '-o', '--debug', path, url] you_get.main()
def test(): sys.argv = ['you-get', '-u', 'https://www.youtube.com/watch?v=9HkeZ8w4z6c'] you_get.main()
def setMovesizeDow(self): sys.argv = ['you-get','-o',self.savePath,self.movesize,self.url] you_get.main()
def defaDown(self): sys.argv = ['you-get','-o',self.savePath,self.url] you_get.main()
def moveIfo(self): sys.argv = ['you-get',self.indexInfo,self.url] you_get.main()
def download(url, path): sys.argv = ['you-get', '-o', path, url] you_get.main()
out['danmaku_url'] = ve.danmuku if getattr(ve, 'referer', None): out['referer'] = ve.referer else: try: out['referer'] = ve.streams['__default__']['refer'] except KeyError: pass if pretty_print: print(json.dumps(out, indent=4, sort_keys=True, ensure_ascii=False)) else: print(json.dumps(out)) import you_get.json_output you_get.json_output.output = output # Patch bilibili def get_danmuku_xml(cid): return 'http://comment.bilibili.com/{}.xml'.format(cid) from you_get.extractors import bilibili bilibili.get_danmuku_xml = get_danmuku_xml # Run you-get if __name__ == '__main__': you_get.main(repo_path=_filepath)
def Download(url, file_path): sys.argv = ['you-get', '-o', file_path, '-O', 'News', url] you_get.main()
def run(self): sys.argv = ['you-get', '-o', self.path, self.url, "--debug"] you_get.main() self._signal.emit("1")
def download_videos(path_now, url): # 调用指令,-o 是指令的参数,sys操纵系统模块 sys.argv = ['you-get', '-o', path_now, url] # 默认下载是flv格式 you_get.main()