예제 #1
0
def admin():
    if request.method == "GET":
        videos = Video.objects()
        return render_template('admin.html', videos = videos)

    elif request.method == "POST":
        form = request.form
        link = form['link']

        ydl = YoutubeDL()

        data = ydl.extract_info(link, download = False)

        title = data['title']
        thumbnail = data['thumbnail']
        views = data ['view_count']
        youtube_id = data['id']

        video = Video(title = title,
                    thumbnail = thumbnail,
                    views = views,
                    youtube_id = youtube_id,
                    link = link)
        video.save()
        return redirect(url_for("admin"))
예제 #2
0
    def insert_video_info_into_db(self):
        title = self.web_driver.find_element_by_css_selector("h1.title").text
        user_container = self.web_driver.find_element_by_tag_name(
            "ytd-video-owner-renderer").text
        channel_name = user_container.split("\n")[0].strip()

        url = self.web_driver.current_url
        Video(title, channel_name, url, COMMENT, datetime.now()).insert()
def admin():
    if 'logged_in' in session:
        if request.method == 'GET':
            all_video = Video.objects()
            return render_template('admin.html', all_video=all_video)
        elif request.method == 'POST':
            form = request.form
            link = form['link']
            ydl = YoutubeDL()
            data = ydl.extract_info(link, download=False)

            new_video = Video(title=data['title'],
                              thumbnail=data['thumbnail'],
                              view=data['view_count'],
                              youtubeid=data['id'])
            new_video.save()
            return redirect(url_for('admin'))
    else:
        return "Đi chỗ khác chơi"
예제 #4
0
def admin():
    if request.method == 'GET':
        if "logged_in" in session:
            videos = Video.objects()
            return render_template('admin.html', videos=videos)
        else:
            return render_template("error.html")
    elif request.method == 'POST':
        form = request.form
        link = form['link']
        data = ydl.extract_info(link, download=False)
        title = data['title']
        thumbnail = data['thumbnail']
        views = data['view_count']
        youtubeid = data['id']
        new_video = Video(title=title,
                          thumbnail=thumbnail,
                          views=views,
                          link=link,
                          youtubeid=youtubeid)
        new_video.save()

        return redirect(url_for('admin'))
def add_video(title, youtube_url, date, subcategory_id):
    video = Video(title, youtube_url, date, subcategory_id)
    insert(video)
예제 #6
0
    def _init_video(self):
        w_videos = []

        w_video = Video()
        w_video.id("45reasons")
        w_video.name("45 Reasons")
        w_video.music("45reasons")
        w_video.url("https://www.youtube.com/embed/9BNABYtjLR4")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("epicstringbattleforwhisky")
        w_video.name("Epic String Battle for Whisky")
        w_video.url("https://www.youtube.com/embed/fFMl31hB4NU")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("injusticeforall")
        w_video.name("Injustice for All")
        w_video.music("injusticeforall")
        w_video.url("https://www.youtube.com/embed/_vcxsC_r3pA")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("endoftime")
        w_video.name("End of Time")
        w_video.music("endoftime")
        w_video.url("https://www.youtube.com/embed/qBnd0j6rItY")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("brokenlegspart2")
        w_video.name("Broken Legs Pt.2")
        w_video.music("brokenlegspart2")
        w_video.url("https://www.youtube.com/embed/LGiwYy-7nJQ")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("thearrival")
        w_video.name("The Arrival")
        w_video.music("thearrival")
        w_video.url("https://www.youtube.com/embed/dMChbNTV_rg")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("coverocean")
        w_video.name("Cover Ocean")
        w_video.url("https://www.youtube.com/embed/Rgz36SCXfLA")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("covertrain")
        w_video.name("Cover Train")
        w_video.url("https://www.youtube.com/embed/JiWLMsMgKgY")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("coverdarrycowlchamber")
        w_video.name("Cover Darry Cowl Chamber")
        w_video.url("https://www.youtube.com/embed/QH2mjk7jt30")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("mindcontrol")
        w_video.name("Mind Control")
        w_video.url("https://www.youtube.com/embed/3FM8urVV4WM")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("aceofspades")
        w_video.name("Ace of Spades")
        w_video.url("https://www.youtube.com/embed/QDig_XMT1a8")
        w_videos.append(w_video)

        w_video = Video()
        w_video.id("teaseryblues")
        w_video.name("Teaser")
        w_video.url("https://www.youtube.com/embed/X8nXyU7ziss")
        w_videos.append(w_video)

        self._manager_video.up_sert_many(w_videos)
예제 #7
0
파일: main.py 프로젝트: pduy/hash-code-tub
def parseInputs():
    script, filename = argv

    txt = open(filename)

    lines = txt.read().split('\n')

    first_line = lines[0]

    (no_videos, no_endpoints, no_requests, no_caches,
     cache_size) = intTuple(first_line)

    video_size = intTuple(lines[1])

    debug("Video %d" % no_videos)
    debug("Videos size : ")
    debug(video_size)

    videos = []
    for i in range(no_videos):
        videos.append(Video(i, video_size[i]))
    debug(videos)

    caches = []
    for i in range(no_caches):
        caches.append(Cache(i, cache_size, []))

    debug(caches)

    idx = 2

    # loop endpoint
    endpoints = []
    endpoint_id = 0
    while (no_endpoints > 0):
        (latency_to_dc, no_caches) = intTuple(lines[idx])
        idx = idx + 1

        latency_to_caches = dict()
        for i in range(no_caches):
            (cache_server, latency) = intTuple(lines[idx])
            latency_to_caches[cache_server] = latency
            idx = idx + 1

        en = Endpoint(endpoint_id, latency_to_caches, latency_to_dc)
        endpoints.append(en)

        endpoint_id = endpoint_id + 1
        no_endpoints = no_endpoints - 1

    debug(endpoints)

    requests = []
    while (no_requests > 0):
        (video_id, endpoint_id, reqs) = intTuple(lines[idx])

        requests.append(Request(video_id, endpoint_id, reqs))
        idx = idx + 1
        no_requests = no_requests - 1

    debug(requests)

    idx = 2

    return (caches, endpoints, requests, videos)