Пример #1
0
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')
Пример #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
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)