Пример #1
0
def load_video_meta(vid, express=False):
    # logr = logging.getLogger(vid)

    vid_meta = dict()
    wpage = get_page("video", vid)  # wpage = watch_page
    if (wpage["code"] != 200) or (wpage["len"] == 0):  # only HTML code for success is 200 OK
        raise ytd_exception_meta("PAGE_FETCH_ERR", wpage, vid_meta, "HTTP Error Code-{}".format(wpage["code"]))

    if express:
        vid_meta = parse_watch_page_express(wpage)
        return vid_meta

    else:
        vid_meta = parse_watch_page(wpage)
        if vid_meta["player_args"] == None:
            raise ytd_exception_meta("BAD_PAGE", wpage, vid_meta, "")

        vid_meta["stream_map"] = parse_stream_map(vid_meta)
        if not (vid_meta["stream_map"]):
            raise ytd_exception_meta("NO_STREAMS", wpage, vid_meta, "")

        return vid_meta
Пример #2
0
	for opt, arg in opts:
		if opt in ("-p", "--playlist"):
			plref = arg
		if opt in ("-o", "--outfile"): 
			outfile = arg

	if ( plref  == "" ): 
		logm.critical("Missing playlist. Either supply item (id/url)  OR file with url_list") 
		logm.critical(usage_str,sys.argv[0])
		sys.exit(2)

	return plref, outfile

#---------------------------------------------------------------
# Main function

logm = setup_main_logger() 

plref, outfile = parse_arguments(sys.argv[1:]) 

plid = get_plid_from_url(plref) 

pl_page = get_page("list",plid) 

plist = extract_playlist(plid,pl_page) 

save_playlist(plist,outfile) 
print_playlist_stats(plist)