示例#1
0
def uploadVideo(
    title, description="", source="output/video.mp4", status="private", thumbnail=""
):
    # loggin into the channel
    channel = Channel()
    channel.login("client_secret.json", "credentials.storage")

    # setting up the video that is going to be uploaded
    video = LocalVideo(file_path=source)

    tags = []

    # setting snippet
    video.set_title(title)
    video.set_description(description)
    video.set_tags(tags)
    video.set_category("entertainment")

    # setting status
    video.set_embeddable(True)
    video.set_license("youtube")
    video.set_privacy_status(status)
    video.set_public_stats_viewable(True)

    # setting thumbnail
    if len(thumbnail) > 3:
        video.set_thumbnail_path(thumbnail)

    # uploading video and printing the results
    video = channel.upload_video(video)
    print(video.get_video_id())
    print(video)
示例#2
0
def test_local_video_negative_function():
    # snippet variables
    file_path = os.path.realpath(__file__)
    bad_file_path = "not_valid"
    thumbnail_path = "not_valid"
    title = "-" * (youtube_api.MAX_YOUTUBE_TITLE_LENGTH + 1)
    description = "-" * (youtube_api.MAX_YOUTUBE_DESCRIPTION_LENGTH + 1)
    tags = ["-" * (youtube_api.MAX_YOUTUBE_TAGS_LENGTH + 1)]
    string_category = "not a category"
    id_category = -1
    default_language = False

    # status variables
    embeddable = "not_valid"
    license = "not_valid"
    privacy_status = "not_valid"
    public_stats_viewable = "not_valid"
    publish_at = False

    video = LocalVideo(file_path)

    # misc test
    with pytest.raises(Exception):
        video.set_file_path(bad_file_path)
    with pytest.raises(Exception):
        video.set_thumbnail_path(thumbnail_path)

    # snippet test
    with pytest.raises(Exception):
        video.set_title(title)
    with pytest.raises(Exception):
        video.set_title(True)
    with pytest.raises(Exception):
        video.set_description(description)
    with pytest.raises(Exception):
        video.set_description(True)
    with pytest.raises(Exception):
        video.set_tags(tags)
    with pytest.raises(Exception):
        video.set_tags(True)
    with pytest.raises(Exception):
        video.set_category(string_category)
    with pytest.raises(Exception):
        video.set_category(id_category)
    with pytest.raises(Exception):
        video.set_default_language(default_language)

    # status test
    with pytest.raises(Exception):
        video.set_embeddable(embeddable)
    with pytest.raises(Exception):
        video.set_license(license)
    with pytest.raises(Exception):
        video.set_privacy_status(privacy_status)
    with pytest.raises(Exception):
        video.set_public_stats_viewable(public_stats_viewable)
    with pytest.raises(Exception):
        video.set_publish_at(publish_at)
示例#3
0
def upload():
    myfile = "src/vidnum.txt"
    with open(myfile, "r") as f:
        num = int(f.read())
    print(num)
    print(type(num))
    with open(myfile, "w") as f:
        f.write(str(num + 1))

    # setting up the video that is going to be uploaded
    video = LocalVideo(file_path="final.mp4")

    # setting snippet
    video.set_title("Top memes I found on Reddit #" + str(num))
    video.set_description('''Top memes I found on Reddit #

        Like, Share and Subscribe for daily videos


        Music used in the Video:
        Kevin MacLeod - Fluffing A Duck

        Memes from subreddits:

        r/memes,r/dankmemes,r/me_irl,r/HistoryMemes,r/BlackPeopleTwitter,r/facepalm,r/ihadastroke,r/woosh,r/technicallythetruth

        Disclaimer:
        I do not own any of the images shown in this video and I am not the creator of these memes.
''')

    video.set_tags([
        "memes", "reddit", "reddit memes", "reddit compilation",
        "meme compilation", "funny", "dank memes", "funny memes", "top memes",
        "top reddit", "top"
    ])
    video.set_default_language("en-US")

    # setting status
    video.set_embeddable(True)
    video.set_license("creativeCommon")
    video.set_privacy_status("public")
    video.set_public_stats_viewable(True)

    img = []
    for file in glob.glob("processed/*.jpg"):
        img.append(file)

    rand = random.randrange(0, len(img))

    # setting thumbnail
    video.set_thumbnail_path(img[rand])

    # uploading video and printing the results
    video = channel.upload_video(video)
    print(video.id)
    print(video)

    return [video.id, video, img[rand]]
示例#4
0
def send_details():
    # loggin into the channel
    des = open(description_file, 'r')
    des_list = []
    des = des.readlines()
    for l in des:
        des_list.append(l)

    descr = listToString(des_list)
    tit = video_file.split('/')[-1]
    title = tit.split('.')[0]
    tags = tit.split(' ')

    channel = Channel()
    channel.login("client_secrets.json", "credentials.storage")

    # setting up the video that is going to be uploaded
    video = LocalVideo(file_path=video_file)

    # setting snippet
    video.set_title(title)
    video.set_description(descr)
    video.set_tags(tags)
    # video.set_category("health")
    # video.set_default_language("english")

    # setting status
    video.set_embeddable(True)
    video.set_license("creativeCommon")
    video.set_privacy_status("public")
    video.set_public_stats_viewable(True)

    # setting thumbnail
    video.set_thumbnail_path(thumbnail_file)

    # uploading video and printing the results
    video = channel.upload_video(video)
    print(video.get_video_id())
    print(video)

    # liking video
    video.like()
    window.destroy()
示例#5
0
def upload_video(c, test_flag=False):

    # loggin into the channel
    channel = Channel()
    channel.login("client_secret.json", "credentials.storage")

    # setting up the video that is going to be uploaded
    video = LocalVideo(file_path="video/" + c.VIDEO_NAME)

    # setting snippet
    title = 'GBPsim-py - ' + c.SONG_NAME + ' ' + c.DIFFICULTY.upper()
    video.set_title(title)

    description = 'https://github.com/thtl1999/GBPsim-py\n' + c.SONG_INFO + '\nThis video is uploaded with automatic process'
    video.set_description(description)
    # video.set_tags(["this", "tag"])
    video.set_category("gaming")
    video.set_default_language("ja")

    # setting status
    video.set_embeddable(True)
    video.set_license("youtube")

    if test_flag:
        video.set_privacy_status("private")
    else:
        video.set_privacy_status("public")

    video.set_public_stats_viewable(True)

    # setting thumbnail
    #video.set_thumbnail_path("test_thumb.png")
    # video.set_playlist("")

    # uploading video and printing the results
    video = channel.upload_video(video)
    print(video.id)
    print(video)

    # liking video
    # video.like()
示例#6
0
def test_local_video_constructor():
    file_path = (
        os.path.dirname(os.path.abspath(__file__))
        + os.sep
        + "test_local_video.py"
    )
    title = "this is a title"
    description = "this is a description"
    tags = ["this", "is" "a", "tag"]
    string_category = "film"
    id_category = 1
    default_language = "english"

    # status variables
    embeddable = True
    license = "youtube"
    privacy_status = "public"
    public_stats_viewable = True
    publish_at = "9"

    # snippet test
    video = LocalVideo(
        file_path=file_path,
        title=title,
        description=description,
        tags=tags,
        category=string_category,
        default_language="english",
    )

    assert video.get_file_path() == file_path, "Wrong file path: " + str(
        video.get_file_path()
    )
    assert video.get_title() == title, "Wrong title:" + str(video.get_title())
    assert video.get_description() == description, "Wrong description: " + str(
        video.get_description()
    )
    assert video.get_tags() == tags, "Wrong tags: " + str(video.get_tags())
    assert video.get_category() == id_category, "Wrong category: " + str(
        video.get_category()
    )
    assert (
        video.get_default_language() == default_language
    ), "Wrong language: " + str(video.get_default_language())

    assert video.snippet_set is True, "Wrong snippet set: " + str(
        video.snippet_set
    )

    # status test
    assert video.status_set is False, "Wrong status set" + str(video.status_set)

    video.set_embeddable(embeddable)
    video.set_license(license)
    video.set_privacy_status(privacy_status)
    video.set_public_stats_viewable(public_stats_viewable)
    video.set_publish_at(publish_at)

    assert video.get_embeddable() == embeddable
    assert video.get_license() == license
    assert (
        video.get_privacy_status() == privacy_status
    ), "Privacy Wrong: " + str(video.get_privacy_status())
    assert video.get_public_stats_viewable() == public_stats_viewable
    assert video.get_publish_at() == publish_at

    assert video.status_set is True, "Wrong video status: " + str(
        video.status_set
    )

    video.set_thumbnail_path(file_path)
    assert video.get_thumbnail_path() == file_path

    str(video)
示例#7
0
channel = Channel()
channel.login("client_secret.json", "credentials.storage")

# setting up the video that is going to be uploaded
video = LocalVideo(file_path="test_vid.mp4")

# setting snippet
video.set_title("My Title")
video.set_description("This is a description")
video.set_tags(["this", "tag"])
video.set_category("gaming")
video.set_default_language("en-US")

# setting status
video.set_embeddable(True)
video.set_license("creativeCommon")
video.set_privacy_status("private")
video.set_public_stats_viewable(True)

# setting thumbnail
#video.set_thumbnail_path("test_thumb.png")
video.set_playlist("PLDjcYN-DQyqTeSzCg-54m4stTVyQaJrGi")

# uploading video and printing the results
video = channel.upload_video(video)
print(video.id)
print(video)

# liking video
video.like()