def populate():
    videoList = crawl("https://www.youtube.com/watch?v=09R8_2nJtjg&list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI")
    videoList += crawl("https://www.youtube.com/watch?v=CevxZvSJLk8&list=PLWRJVI4Oj4IaYIWIpFlnRJ_v_fIaIl6Ey")
    
    for url in videoList:
        videoid = url.split("=")[1]
        name = getVideoName(videoid)
        add_video(name, videoid)
示例#2
0
def populate():
    user1 = add_user("test1", "pass", "*****@*****.**")
    user2 = add_user("test2", "pass", "*****@*****.**")
    user3 = add_user("test3", "pass", "*****@*****.**")
    user4 = add_user("test4", "pass", "*****@*****.**")
    users = [user1, user2, user3, user4]

    # add a score for each user
    for user in users:
        correctAnswers = randint(0, 9)
        score = randint(0, 15)
        add_score(user, correctAnswers * score, correctAnswers,
                  correctAnswers + 2)

    # add a second score for each user
    for user in users:
        correctAnswers = randint(0, 9)
        score = randint(0, 15)
        add_score(user, correctAnswers * score, correctAnswers,
                  correctAnswers + 2)

    # add a playlist of videos
    # needs to be in format:
    # https://www.youtube.com/watch?v=<VIDEO_ID>&list=<PLAYLIST_ID>
    videoList = crawl(
        "https://www.youtube.com/watch?v=CevxZvSJLk8&list=PLWRJVI4Oj4IaYIWIpFlnRJ_v_fIaIl6Ey"
    )

    for url in videoList:
        videoid = url.split("=")[1]
        name = getVideoName(videoid)
        add_video(name, videoid)
        print url
示例#3
0
def populate(playlist):
    videoList = crawl(playlist)

    for url in videoList:
        videoid = url.split("=")[1]
        name = getVideoName(videoid)
        add_video(name, videoid)
        print url
示例#4
0
def populate():
    print "inside populate"
    videoList = crawl(
        "https://www.youtube.com/watch?v=CevxZvSJLk8&list=PLWRJVI4Oj4IaYIWIpFlnRJ_v_fIaIl6Ey"
    )

    for url in videoList:
        videoid = url.split("=")[1]
        name = getVideoName(videoid)
        add_video(name, url, videoid)
        print url
示例#5
0

###########################
#
# Beginning of the prog
#
###########################
# timer
startTime = time.time()

playlistFile = "playlist.txt"

fWrite = open(playlistFile, 'a')
if len(sys.argv) > 1:
    url = sys.argv[1]  # the url from command
    final_url = crawl(url)

    #open file and read it
    fRead = open(playlistFile, 'r')
    listDL = list(fRead)
    fRead.close()

    i = 0
    threads = []
    while i < len(final_url):
        thread = OneDownloader(final_url[i])
        i += 2
        thread.start()
        threads.append(thread)

    print "===>>> Number of Thread alive " + ` threading.activeCount() `
			print "===>>> " + out[0] + ' has been already downloaded'

###########################
#
# Beginning of the prog
#
###########################
# timer
startTime = time.time()

playlistFile = "playlist.txt"

fWrite = open(playlistFile, 'a')
if len(sys.argv) > 1:
	url = sys.argv[1] # the url from command
	final_url = crawl(url)

	#open file and read it
	fRead = open(playlistFile, 'r')
	listDL = list(fRead)
	fRead.close()

	i = 0
	threads = []
	while i < len(final_url): 
		thread = OneDownloader(final_url[i])
		i += 2
		thread.start()
		threads.append(thread)

	print "===>>> Number of Thread alive "+`threading.activeCount()`
        # get playlist url and name
        if line.count(',') != 1:
            raise Exception('Invalid format for input!! Please check readme.')
        url, folder_name = line.split(',')
        url = url.strip()
        url = "https://www.youtube.com/playlist?list={}".format(url)
        folder_name = folder_name.strip()
        #
    
        # replace space with '_'
        save_folder_name = folder_name.replace(' ', '_')
        #

        # get all video urls for 1 playlist
        print (url)
        all_video_urls = crawl(url)
        #

        # make new folders and be ready for saving videos
        playlist_save_dir_path = os.path.join(save_dir_path, save_folder_name)
        is_playlist_dir = os.path.isdir(playlist_save_dir_path)
        if not is_playlist_dir:
            os.makedirs(playlist_save_dir_path)
            dir_naming_valid = os.path.isdir(playlist_save_dir_path)
            if not dir_naming_valid:
                raise Exception('Please check the name of your folder-{}! Maybe invalid in your system: {}'
                                .format(folder_name, platform.platform()))
            else:
                print("Create directory '{}' done!".format(playlist_save_dir_path))
                print("Calling you-get...Wait...".format(playlist_save_dir_path))
        #
示例#8
0
    channelId = BOILER_ROOM_CHANNELID,
    order = "viewCount",
    maxResults=50
    ).execute()
    videos = []
    v = dict()
    titles = []
    for search_result in search_response.get("items", []):
        if search_result["id"]["kind"] == "youtube#video":
            videos.append("%s" % str(search_result["id"]["videoId"]))
            v[search_result["id"]["videoId"]] = search_result["snippet"]["title"]
            titles.append("%s" % search_result["snippet"]["title"])

    return videos

videos = crawl("https://www.youtube.com/watch?v=vy-k0FopsmY&list=PUGBpxWJr9FNOcFYA5GkKrMg")


def parse_videos(videos):
    d = dict()
    for vid in videos:
        d[vid] = get_stats(vid)
    return d
	# Create your views here.

def get_stats(videoId):
    # parse_videos(videos)
    search_response = youtube.videos().list(
    part="statistics,snippet",
    id=videoId,
    fields = "items(statistics(viewCount), snippet(title,publishedAt))"