Ejemplo n.º 1
0
def yg_main(**kwargs):
    """Main entry point.
    you-get (legacy)
    """
    #from you_get.common import *
    from you_get.common import main
    main(**kwargs)
Ejemplo n.º 2
0
 def downloadVideo(videoLink, videoPath, videoName):
     fullname = os.path.join(videoPath, videoName + ".flv")
     if not os.path.isfile(fullname):
         sys.argv = ['you-get', '-o', videoPath, '-O', videoName, videoLink]
         you_get.main()
     else:
         print("[已存在-]" + videoName)
Ejemplo n.º 3
0
 def run(dic, urll):
     for u in urll:
         # try:
         sys.argv = ['you-get', '-o', dic, u]
         you_get.main()
         # except Exception as e:
         #     print(e)
     return
Ejemplo n.º 4
0
def downloadvideos(avnumbers):
    for avnumber in avnumbers:
        filename = time.strftime('%Y-%m-%d', time.localtime(
            time.time())) + "_" + avnumber
        weblink = "https://www.bilibili.com/video/" + avnumber + "/"
        sys.argv = [
            'you-get', '-o', dir, '--output-filename', filename, weblink
        ]
        you_get.main()
Ejemplo n.º 5
0
def download(uri):
    '''
    视频下载
    :param self:
    :param uri:
    :return:
    '''
    sys.argv = ['you-get', uri]
    you_get.main()
Ejemplo n.º 6
0
 def run(dic, urll, kstart=None):
     # kstart is the last number printed on the screen.
     k = 0
     kt = len(urll)
     for u in urll:
         k += 1
         if kstart:
             if k <= kstart:
                 continue
         try:
             sys.argv = ['you-get', '-o', dic, u]
             you_get.main()
         except Exception as e:
             print(e)
             print('*Loss one. The url is:{}'.format(u))
         print('{}/{} done.'.format(k, kt))
     return
Ejemplo n.º 7
0
def downloadUperVod(uper_Uid_num, pager_total_num, directory):
    # transfer the uper's Uid into string
    uper_Uid_str = str(uper_Uid_num)
    # In  order to cover the last video list page in following for loop
    pager_total_num = pager_total_num + 1
    for page_index in range(1, pager_total_num):
        page_index_num = page_index
        page_index_str = str(page_index_num)
        page_url = 'https://space.bilibili.com/' + uper_Uid_str + '/video?tid=0&page=' + page_index_str
        # Open FireFox
        browser = webdriver.Firefox()
        # Open uper's video list page
        browser.get(page_url)
        time.sleep(2)
        # Find all video href in this video list page
        vod_urlList = browser.find_elements_by_class_name('cover')
        # Create a file path for each video list page,all videos in this page will be downloaded in individual file
        Downlaod_directory = directory + '/page' + page_index_str
        isExists = os.path.exists(Downlaod_directory)
        if not isExists:
            os.makedirs(Downlaod_directory)
        href_list = []
        for url in vod_urlList:
            href = url.get_attribute("href")
            if href not in href_list:
                href_list.append(href)
        browser.close()
        # Counter of the downloaded video in this page
        count = 0
        for vod_href in href_list[count:]:
            count = count + 1
            print('Total videos in this page :', len(href_list))
            print(vod_href)
            print('Downloading the ', page_index, 'th page ', count,
                  'th video')
            try:
                sys.argv = ['you-get', '-o', Downlaod_directory, vod_href]
                you_get.main()
            except TypeError:
                time.sleep(2)
                sys.argv = [
                    'you-get', '-o', Downlaod_directory, vod_href, '--debug'
                ]
                you_get.main()
Ejemplo n.º 8
0
    def __use_youget(self,down_url_dict):
        redownDict={}
        for i in list(down_url_dict.keys()):
            try:
                sys.argv=['you-get',down_url_dict[i]]
                you_get.main()
                self.__clearTerminal()
            
            except:
                print("""


                """)
                print("下载{}的过程出了点问题,稍后会重新下载".format(down_url_dict[i]))
                print("""


                """)
                redownDict[i] = down_url_dict[i]
            
        return redownDict
Ejemplo n.º 9
0
    def ProcessOne(self):
        try:
            if os.path.exists(self.directory) == False:
                os.makedirs(self.directory)
            # 去除特殊字符,否则下载文件会有问题
            fileName = re.sub('[\/:*?"<>|]', '-', self.title)
            self.newUrl = CheckRedirectUrl(self.url)
            if self.newUrl is None:
                raise Exception("CheckRedirectUrl " + self.url + " Fail.")

            sys.argv = [
                'you-get', '--debug', '-o', self.directory, '-O',
                self.time + "_" + fileName, self.newUrl
            ]
            self.logger.info("start download " + fileName + " -- " +
                             self.newUrl)
            you_get.main()
            self.logger.info("end download")
            return True
        except Exception as ex:
            self.logger.error("Downloader Error: " + fileName + " -- " +
                              self.url + ' -- newUrl: ' + self.newUrl)
            return False
Ejemplo n.º 10
0
def main(path, video_id):
    video = require_video(video_id)
    if (video == -1):
        print("video id为:" + str(video_id) + "的视频不存在")
    elif (int(video) >= 1):  # 浏览数判断
        print("video id为:" + str(video_id) + "的视频的播放量为:" + str(video))

        directory = path  # 设置下载目录
        url = 'https://www.bilibili.com/video/av{}/'.format(
            video_id)  # 需要下载的视频地址
        title = bilibili_class.getVideo_title(url)
        tag = '萌'  # 可修改标签,下载不同视频
        result = tag in title
        if result is True:  # 符合标签及浏览数指标,可以下载
            sys.argv = ['you-get', '-o', directory,
                        url]  # sys传递参数执行下载,就像在命令行一样
            you_get.main()
            print('可下载')
            return title, url

    else:
        pass
    time.sleep(1)
Ejemplo n.º 11
0
    def _analysis(self):
        """ 分析视频信息 """

        sys.argv = [
            '/usr/local/python3/bin/you-get', '--url', '--json',
            self.url['url']
        ]
        output = OutputPrint()
        sys.stdout = output
        error = ''
        try:
            main()
            result = output.buffer
        except Exception as e:
            error = e
        finally:
            output.flush()
            output.reset()
        if error != '':
            raise error

        self.analysisInfo = result
        data = json.loads(result)
        self.title = data['title']
def download(url, path):
    sys.argv = ['you-get', '-o', path, url]
    you_get.main()
Ejemplo n.º 13
0
def download_video(vid=8786599, vdir=r"T:\\bili_video"):
    url = r"https://www.bilibili.com/video/av{0}/".format(vid)
    sys.argv = ["you-get", "-o", vdir, url]
    you_get.main()
Ejemplo n.º 14
0
def get_vidio():
    directory = r'D:\\下载\\Go视频教程'
    for i in range(1, 4):
        url = "https://www.bilibili.com/video/av92510911?p=%s" % i  #需要下载的视频地址
        sys.argv = ['you-get', '-o', directory, url]  #sys传递参数执行下载,就像在命令行一样
        you_get.main()
Ejemplo n.º 15
0
def download(directory, aid):
    url = 'https://www.bilibili.com/video/av' + str(aid) + '/'  # 需要下载的视频url
    sys.argv = ['you-get', '-o', directory, url]  # sys传递参数执行下载,就像在命令行一样
    you_get.main()
Ejemplo n.º 16
0
import re, sys
from bs4 import BeautifulSoup
from urllib import request, parse
from you_get import common as yg

down_path = 'e:/video_down/绝命毒师'
# url_1 = 'https://tv.sohu.com/v/MjAxMjA5MjgvbjM1NDEyNjQ4MS5zaHRtbA==.html'
# url_2 = 'https://tv.sohu.com/v/MjAxMzA4MTIvbjM4Mzk3NTg4My5zaHRtbA==.html'
# url_3 = 'https://tv.sohu.com/v/MjAxMzA4MjgvbjM1NDEyNjQ4MS5zaHRtbA==.html'
# url = 'https://www.iqiyi.com/v_19rrlhjlvc.html#vfrm=2-4-0-1'
url = 'http://v.youku.com/v_show/id_XMzY3OTQ0Nzk5Mg==.html?spm=a2h0j.11185381.listitem_page1.5!3~A&&s=7c1ecdcd435c11e6bdbb'
sys.argv = ['you-get', '-o', down_path, url]
yg.main()
Ejemplo n.º 17
0
 def download(self,name,link):
 	sys.argv=['you-get','-O',name,'--format=mp4sd',link]
 	you_get.main()
Ejemplo n.º 18
0
import sys
from you_get import common

url = r'https://www.youtube.com/watch?v=4GLMZtAEaVs'

sys.argv = ['you-get',url]

common.main()
Ejemplo n.º 19
0
def _call_method1():
    sys.argv = ['you-get', '-h']
    t = you_get.main()
Ejemplo n.º 20
0
def multi_process(k_and_v):
    url = k_and_v['url']
    file_name = k_and_v['file_name']
    print('url', url, 'file_name', file_name)
    sys.argv = ['you-get', '-o', save_to, '--no-caption', url, '-O', file_name]
    you_get.main()
Ejemplo n.º 21
0
def _call_method3():
    you_get.main()
Ejemplo n.º 22
0
'''
Description: you_get 下载视频
Author: HCQ
Company(School): UCAS
Email: [email protected]
Date: 2021-01-03 14:22:52
LastEditTime: 2021-01-06 21:26:33
FilePath: /Spider/practice/10bilibili视频爬取下载/02-1bilibili_you-get.py
'''
import sys
from you_get import common as you_get  #导入you-get库

# 单视频下载
directory = '/home/hcq/下载/collage'  #设置下载目录
url = 'https://www.bilibili.com/video/BV194411G72j '  #需要下载的视频地址
sys.argv = ['you-get', '-o', directory, url,
            '-l']  #sys传递参数执行下载,就像在命令行一样;‘-o’后面跟保存目录。
you_get.main()

# # 自制视频列表下载
# directory = '/home/hcq/下载/collage'                          #设置下载目录
# urls = ['https://www.bilibili.com/video/BV194411G72j '   , 'https://www.bilibili.com/video/BV1Ai4y137pr?from=search', 'https://www.bilibili.com/video/BV1wi4y177qJ?from=search']   #需要下载的视频地址
# for url in urls:
#     print(url)
#     sys.argv = ['you-get', '-o', directory, url, '-l']          #sys传递参数执行下载,就像在命令行一样;‘-o’后面跟保存目录。
#     you_get.main()
Ejemplo n.º 23
0
def fun(url):
    # url = f"https://www.bilibili.com/bangumi/play/ep2850{i}" # 需要下载的视频地址
    sys.argv = ['you-get', '--playlist', '-o', directory,
                url]  # sys传递参数执行下载,就像在命令行一样
    you_get.main()