예제 #1
0
from youtube3 import YoutubeClient
from oauth2client.tools import argparser
import os

if __name__ == "__main__":
    args = argparser.parse_args()
    youtube_client = YoutubeClient(
        os.path.join(os.path.dirname(__file__), 'client_secrets.json'))

    recommended = youtube_client.get_recommended()
    print(recommended)
예제 #2
0
    with open(configuration_file) as f:
        config = yaml.safe_load(f)
    if not os.path.exists(config['output_path']):
        os.makedirs(config['output_path'])

    args = parser.parse_args()
    playlist_id = config.get('playlist_id', None)
    playlist_ids = config.get('playlist_ids', None)
    only_metadata = config.get('only_metadata', None)

    video_range_keep = config.get('video_range_keep', None)
    video_range_train = config.get('video_range_train', None)
    video_range_test = config.get('video_range_test', None)
    target_directory = config.get('target_directory', None)
    category_mapping = config.get('category_mapping', None)
    youtube_client = YoutubeClient(config['client_json_file'])
    if playlist_id:
        playlist_names = [youtube_client.playlist_name(playlist_id)]
    else:
        playlist_names = [
            youtube_client.playlist_name(playlist_id)
            for playlist_id in playlist_ids
        ]

    target_key = target_directory + '_' + sanitize_filename(target_directory,
                                                            restricted=True)
    output_path = config.get('output_path', '.')
    video_output_path = os.path.join(output_path, target_directory, 'videos')
    frame_output_path = os.path.join(output_path, target_directory, 'frames')
    metadata_output_path = os.path.join(output_path, target_directory,
                                        'metadata')
import operator

from blogspotapi import BlogClient, BlogPost, BlogRepository
from amara.amara_env import amara_headers

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--blogId')
    parser.add_argument('--mongo_connection',
                        type=str,
                        default='mongodb://localhost:27017/musicblogs')
    args = parser.parse_args()
    channelsDict = dict()
    client_secrets_file = os.path.join(os.path.dirname(__file__),
                                       'client_secrets.json')
    youtube_client = YoutubeClient(client_secrets_file)
    blog_client = BlogClient(client_secrets_file)
    blog_repository = BlogRepository(args.mongo_connection, args.blogId,
                                     amara_headers)
    blogId = args.blogId
    for post_id, blog_post in blog_repository.posts_map.items():
        try:
            videoId = blog_post.videoId
            print('Found video ' + videoId)
            youtube_client.like_video(videoId)
            channelId = youtube_client.get_channel_id(videoId)
            print('Found channel ' + channelId)
            if not channelId in channelsDict:
                channelsDict[channelId] = 0
            channelsDict[channelId] = channelsDict[channelId] + 1
            print('Found channel ' + channelId + ':' +
if __name__ == "__main__":
    argparser.add_argument('--blogId')
    argparser.add_argument('--outDir')
    argparser.add_argument('--mongo_connection',
                           type=str,
                           default='mongodb://localhost:27017/musicblogs')
    argparser.add_argument('--with_subtitles',
                           dest='with_subtitles',
                           action='store_true')
    argparser.add_argument('--no-with_subtitles',
                           dest='with_subtitles',
                           action='store_false')
    argparser.set_defaults(with_subtitles=True)
    args = argparser.parse_args()

    youtube_client = YoutubeClient(
        os.path.join(os.path.dirname(__file__), 'client_secrets.json'))
    blog_repository = BlogRepository(args.mongo_connection, args.blogId)

    if (args.outDir is None):
        print(
            "Usage : python download_videos.py --outDir <outputDirectory> --blogId <blogSource> "
        )
        sys.exit(0)

    if not os.path.isdir(args.outDir):
        print("{} does not exist -- creating it".format(args.outDir))
        os.mkdir(args.outDir)

    download_videos(youtube_client,
                    blog_repository,
                    out_dir=args.outDir,
예제 #5
0
from youtube3 import YoutubeClient
from oauth2client.tools import argparser
import os

if __name__ == "__main__":
    argparser.add_argument('--videoId')
    args = argparser.parse_args()
    if args.videoId == None:
        print("required argument --videoId <videoId>")
    else:
        youtube = YoutubeClient(
            os.path.join(os.path.dirname(__file__), 'client_secrets.json'))
        videoInfo = youtube.get_video(args.videoId)
        video_snippet = youtube.get_video_snippet(args.videoId)
        channelId = youtube.get_channel_id(args.videoId)

        print(videoInfo['items'][0]['snippet'])
        print(video_snippet)
        relatedVideos = youtube.get_related_videos(args.videoId)
        print(videoInfo)
        print(channelId)
        print(relatedVideos)