コード例 #1
0
ファイル: main.py プロジェクト: FuckBrains/youtube-video-tool
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_channel_fetch_uploads():
    channel = Channel()

    assert os.path.isfile(CLIENT_SECRET_NAME), "CLIENT SECRET_NAME not valid"

    assert os.path.isfile(CREDENTIALS), "CREDENTIALS is not valid"

    channel.login(CLIENT_SECRET_NAME, CREDENTIALS)

    videos = channel.fetch_uploads()

    for video in videos:
        print(video.get_title())
コード例 #3
0
def test_youtube_video_rating():
    video_id = YOUTUBE_VIDEO_ID

    channel = Channel()

    assert os.path.isfile(CLIENT_SECRET_NAME), "CLIENT SECRET_NAME not valid"
    assert os.path.isfile(CREDENTIALS), "CREDENTIALS is not valid"

    channel.login(CLIENT_SECRET_NAME, CREDENTIALS)

    video = YouTubeVideo(id=video_id, channel=channel.get_login())

    video.dislike()
    video.remove_rating()
    video.like()

    with pytest.raises(Exception):
        video.rate_video("not_valid")
コード例 #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
ファイル: youtube.py プロジェクト: thtl1999/GBPsim-py
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 not_working_channel_upload_video():
    channel = Channel()
    """
    testing this will make too many requests to google which will go over the
    query quota
    """

    assert os.path.isfile(CLIENT_SECRET_NAME), "CLIENT SECRET_NAME not valid"
    assert os.path.isfile(CREDENTIALS), "CREDENTIALS is not valid"

    title = "Time: " + str(datetime.datetime.now())
    download_video()

    channel.login(CLIENT_SECRET_NAME, CREDENTIALS)
    video = LocalVideo(file_path=VIDEO_NAME)
    video.set_title(title)
    video.set_description("This is a description")
    video.set_tags(["this", "tag"])
    video.set_category("film")
    video.set_privacy_status("private")

    assert channel.upload_video(video)
コード例 #7
0
def upload_videos(job: Job):
    video = job['video']
    metadata = job['metadata']

    channel = Channel()
    channel.login(settings.youtube()['client_secret'],
                  settings.youtube()['credentials'])

    playlist_id = get_or_create_playlist(metadata['course'], channel)

    video = LocalVideo(file_path=video)
    video.set_title(
        f"[{metadata['course']}] {metadata['title']} - {metadata['subject']}")
    video.set_description(f"Recorded on {metadata['date']}")
    video.set_default_language("en-US")
    video.set_privacy_status("private")

    video = channel.upload_video(video)
    channel.add_video_to_playlist(playlist_id, video)

    return {'playlist_id': playlist_id, 'video_id': video.id}
コード例 #8
0
ファイル: youBOT.py プロジェクト: GoldwinXS/YouBOT
def upload_to_youtube(file_path, title):
    vtitle = title
    if title[-1] != '?':
        vtitle += '?'
    vtitle = 'R/Askreddit Asks: ' + vtitle
    if len(vtitle) > 100:
        vtitle = vtitle[0:97] + '...'
    tags = [
        'reddit', 'askreddit', 'toadfilms', 'updoot', 'stories'
    ] + title.split()  # manual tags: reddit,askreddit,toadfilms,updoot,stories
    description = vtitle + '   \n Sub for the some of the best AskReddit content freshly handpicked for you!'
    channel = Channel()
    channel.login(
        "client_secret_313020947931-jt1iobi0tetjqoprdub0osjb9r1fmulb.apps.googleusercontent.com.json",
        "credentials.storage")

    video = LocalVideo(file_path=file_path + title + ".mp4", title=vtitle)
    video.set_description(description)
    video.set_tags(tags)
    video.set_category(
        "entertainment"
    )  # available categories: {'film': 1, 'animation': 31, 'autos': 2, 'vehicles': 2, 'music': 10, 'pets': 15, 'animals': 15, 'sports': 17, 'short movies': 18, 'travel': 19, 'events': 19, 'gaming': 20, 'videoblogging': 21, 'people': 22, 'blogs': 22, 'comedy': 34, 'entertainment': 24, 'news': 25, 'politics': 25, 'howto': 26, 'style': 26, 'education': 27, 'science': 28, 'technology': 28, 'nonprofits': 29, 'activism': 29, 'movies': 30, 'anime': 31, 'action': 32, 'adventure': 32, 'classics': 33, 'documentary': 35, 'drama': 36, 'family': 37, 'foreign': 38, 'horror': 39, 'sci-fi': 40, 'fantasy': 40, 'thriller': 41, 'shorts': 42, 'shows': 43, 'trailers': 44}
    video.set_thumbnail_path(file_path + 'thumbnail.png')
    print(video.get_thumbnail_path())
    video.set_privacy_status("public")

    channel.upload_video(video)
    channel.login(
        "client_secret_313020947931-jt1iobi0tetjqoprdub0osjb9r1fmulb.apps.googleusercontent.com.json",
        "credentials.storage")
    channel.set_video_thumbnail(video=channel.fetch_uploads()[0],
                                thumbnail_path=file_path + 'thumbnail.png')
コード例 #9
0
from simple_youtube_api.Channel import Channel
from simple_youtube_api.YouTubeVideo import YouTubeVideo

channel = Channel()
channel.login("client_secret.json", "credentials.storage")
videos = channel.fetch_uploads()

for video in videos:
    print(video)
コード例 #10
0
from simple_youtube_api.Channel import Channel
from simple_youtube_api.LocalVideo import LocalVideo

# 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="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)
コード例 #11
0
from simple_youtube_api.Channel import Channel
from simple_youtube_api.LocalVideo import LocalVideo
import glob
import os
import random
import notifBot

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


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

コード例 #12
0
from simple_youtube_api.YouTubeVideo import YouTubeVideo
from simple_youtube_api.Channel import Channel
from simple_youtube_api.YouTube import YouTube

# youtube = YouTube()
# # API KEY
# youtube.login("AIzaSyBK3ozMZg05M8q9ryLjsb2xm4DbYoNjYpg")

# video = youtube.search_by_video_id("hAvdYjkhIe0")

channel = Channel()
channel.login(
    "./credentials/client_secret_911040133095-q2dq6cph2rfito618pctmlu66hajnup4.apps.googleusercontent.com",
    "./credentials/channel_credentials_UCJoZcIAkUodPyA95oOF-ucQ.json",
)

response = (channel.get_login().videos().update(
    body={
        "id": "w6B6fMwAm5w",
        "snippet": {
            "title":
            "Pranayama for Gradual Kundalini Awakening Patanjali Yoga Sutras 101 Nithyananda satsang 24 Jan 2011",
            "description":
            """This was the 3rd day of the Pranayama discourse by Paramahamsa Nithyananda.  He went deeper into the sutra. Yesterday's technique was for Instant Enlightenment - Whether breathing is going in, out, whatever time or space, if it is creating a thought - stop it. The negative aspect of this is, if your body is not ready for this, you may get frustrated. So the next technique - Don't stop the breathing - If you can't stop the breathing, at least elongate it! Whether it is inhaling, exhaling, holding, whenever you notice that a thought is created - elongate the breathing. This is the technique for gradual enlightenment. This will work for everyone. But it will take time. 

Elongate breathing and you will experience Enlightenment.

Paramashivoham: 22-day Ultimate Spiritual Journey with the Avatar HDH Nithyananda Paramashivam 
Learn more: https://paramashivoham.nithyananda.org""",
            "categoryId": 29,
        },
コード例 #13
0
from simple_youtube_api.YouTubeVideo import YouTubeVideo
from simple_youtube_api.Channel import Channel
from simple_youtube_api.YouTube import YouTube

with open("developer_key", "r") as myfile:
    data = myfile.read().replace("\n", "")

developer_key = data
youtube = YouTube()
youtube.login(developer_key)

video = youtube.search_by_video_id("aSw9blXxNJY")

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

video.update(channel, title="hehe")
コード例 #14
0
def test_channel_regular_function():
    channel = Channel()