def upload_to_youtube(upload, vid_out_file, section, hndl, interval):
    if upload:
        sys.stdout.write("UPLOADING video: %s\n" % vid_out_file)
        args.file = vid_out_file
        
        if interval == makevideo_helper.VALID_INTERVAL_STATUSES[0]:
            args.title = "Vine Compilation " + section + " " + \
                                                        str(hndl.FLDR_DATES[0])
        elif interval == makevideo_helper.VALID_INTERVAL_STATUSES[1]:
            args.title = "Vine Compilation " + section + " " + \
                        str(hndl.FLDR_DATES[0]) + "_" + str(hndl.FLDR_DATES[-1])
        elif interval == makevideo_helper.VALID_INTERVAL_STATUSES[2]:
            args.title = "Vine Compilation " + section + " " + \
                                                    str(hndl.FLDR_DATES[0])[:-3]

        args.description = retreive_youtube_description(sect, hndl)

        if section == "COMEDY":
            args.category = "23"
        elif section == "SPORTS":
            args.category = "17"

        args.privacyStatus = "private"
 
        youtube = upload_video.get_authenticated_service(args)
        try:
            upload_video.initialize_upload(youtube, args)
        except HttpError, e:
            print "An HTTP error %d occurred:\n%s" % (e.resp.status, \
                                                                e.content)
Esempio n. 2
0
def upload(video_name):
    location_formatted = re.sub(r'-.*', '', location).capitalize()
    event_type_formatted = event_type.capitalize()
    if debug:
        sunpise_dir = ''
        video_name = 'test.avi'
    args = Namespace(
        auth_host_name='localhost', 
        auth_host_port=[8080, 8090], 
        category='22', 
        description='Test Description', 
        file=sunpise_dir + video_name, 
        keywords='', 
        logging_level='ERROR',
        noauth_local_webserver=True,
        privacyStatus='public',
        title=location_formatted + ' ' + event_type_formatted + ' - ' + 
            datetime.now().strftime('%d %b %Y')
        )
    youtube = upload_video.get_authenticated_service(args)
    print('\n==> Step 3 of 4 (' +
        datetime.now().strftime('%H:%M') + '): Uploading video...')
    try:
        upload_video.initialize_upload(youtube, args)
    except HttpError as e:
        print(("An HTTP error %d occurred:\n%s" % (e.resp.status, e.content)))
    return
Esempio n. 3
0
def upload_file():
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            resp = jsonify({'message' : 'No file in the request'})
            resp.status_code = 400
            return resp
        file = request.files['file']
        if file.filename == '':
            resp = jsonify({'message' : 'No file selected for uploading'})
            resp.status_code = 400
            return resp
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            extension = filename.split('.')[-1:][0]
            x = datetime.datetime.now()
            innerdir = x.strftime("%x:%X:%f").replace(':','').replace('/','')
            maindir = app.config['UPLOAD_FOLDER']+'/'+innerdir
            os.makedirs(maindir)
            filename  = str(len(os.listdir(maindir))+1)+'.'+extension
            filepath = os.path.join(maindir, filename)
            file.save(filepath)

            title = request.form['title']
            description = request.form['description']
            category = request.form['category']
            keywords = request.form['keywords']
            privacyStatus = request.form['privacyStatus']

            youtube = get_authenticated_service(filename)
            try:
                rs = initialize_upload(youtube, filepath, title, description, category, keywords, privacyStatus)
                resp = jsonify({'message' : rs})
                resp.status_code = 200
                return resp
            except Exception as e:
                resp = jsonify({'message' : "An HTTP error occurred:\n%s" % str(e)})
                resp.status_code = 400
                return resp
        else:
            resp = jsonify({'message' : "only mp4, flv file allowed"})
            resp.status_code = 400
            return resp
    else:
        resp = jsonify({'message' : "Invalid request"})
        resp.status_code = 500
        return resp
    
    resp = jsonify({'message' : "Invalid request"})
    resp.status_code = 500
    return resp
Esempio n. 4
0
def create_youtube_via_api(notes, video_file, show_id, audio_metadata,
                           discourse_link):
    print "Uploading to YouTube..."
    soup = BeautifulSoup(notes)
    description = soup.get_text().replace("[display_podcast]", "").replace(
        "[forum_post_link]",
        "Share your thoughts on the show at %s" % discourse_link)

    tags = None
    body = dict(
        snippet=dict(
            title="Bad Voltage " + audio_metadata["title"],
            description=description,
            tags=tags,
            categoryId=28  # science and tech
        ),
        status=dict(privacyStatus="public"  # can be "public"
                    ))

    if not LIVE:
        print "\n*** This is not running on the live server, so skipping the YouTube upload"
        print "The posted data would have been:"
        print body
        return

    # Call the API's videos.insert method to create and upload the video.
    from oauth2client.tools import argparser
    args = argparser.parse_args('')
    youtube = upload_video.get_authenticated_service(args)
    insert_request = youtube.videos().insert(
        part=",".join(body.keys()),
        body=body,
        # The chunksize parameter specifies the size of each chunk of data, in
        # bytes, that will be uploaded at a time. Set a higher value for
        # reliable connections as fewer chunks lead to faster uploads. Set a lower
        # value for better recovery on less reliable connections.
        #
        # Setting "chunksize" equal to -1 in the code below means that the entire
        # file will be uploaded in a single HTTP request. (If the upload fails,
        # it will still be retried where it left off.) This is usually a best
        # practice, but if you're using Python older than 2.6 or if you're
        # running on App Engine, you should set the chunksize to something like
        # 1024 * 1024 (1 megabyte).
        media_body=upload_video.MediaFileUpload(video_file,
                                                chunksize=1024 * 1024,
                                                resumable=True))
    youtube_id = upload_video.resumable_upload(insert_request)
    return ('<iframe width="560" height="315" '
            'src="https://www.youtube.com/embed/%s" '
            'frameborder="0" allowfullscreen></iframe>') % youtube_id
def create_youtube_via_api(notes, video_file, show_id, audio_metadata, discourse_link):
    print "Uploading to YouTube..."
    soup = BeautifulSoup(notes)
    description = soup.get_text().replace("[display_podcast]", "").replace(
        "[forum_post_link]", "Share your thoughts on the show at %s" % discourse_link)

    tags = None
    body=dict(
        snippet=dict(
            title="Bad Voltage " + audio_metadata["title"],
            description=description,
            tags=tags,
            categoryId=28 # science and tech
        ),
        status=dict(
            privacyStatus="public" # can be "public"
        )
    )

    if not LIVE:
        print "\n*** This is not running on the live server, so skipping the YouTube upload"
        print "The posted data would have been:"
        print body
        return

    # Call the API's videos.insert method to create and upload the video.
    from oauth2client.tools import argparser
    args = argparser.parse_args('')
    youtube = upload_video.get_authenticated_service(args)
    insert_request = youtube.videos().insert(
        part=",".join(body.keys()),
        body=body,
        # The chunksize parameter specifies the size of each chunk of data, in
        # bytes, that will be uploaded at a time. Set a higher value for
        # reliable connections as fewer chunks lead to faster uploads. Set a lower
        # value for better recovery on less reliable connections.
        #
        # Setting "chunksize" equal to -1 in the code below means that the entire
        # file will be uploaded in a single HTTP request. (If the upload fails,
        # it will still be retried where it left off.) This is usually a best
        # practice, but if you're using Python older than 2.6 or if you're
        # running on App Engine, you should set the chunksize to something like
        # 1024 * 1024 (1 megabyte).
        media_body=upload_video.MediaFileUpload(video_file, chunksize=1024*1024, resumable=True)
    )
    youtube_id = upload_video.resumable_upload(insert_request)
    return ('<iframe width="560" height="315" '
            'src="https://www.youtube.com/embed/%s" '
            'frameborder="0" allowfullscreen></iframe>') % youtube_id
- Python
- OpenCV
- gTTS
- ffmpeg 
- The YouTube API 

More content coming soon! 

Code used to generate and upload the video @ https://github.com/sidpalas/devops-directive-hello-world

http://devopsdirective.com
'''

    # Creating the namespace directly (rather than using argparse)
    # enabled me to make the video description to span multiple lines
    args = Namespace(
        file='hello_world_video_and_audio.mkv',
        title=
        'Hello Youtube! (AUDIO & VIDEO generated and uploaded with python)',
        description=video_description,
        category='28',
        keywords='',
        privacyStatus='public',
        logging_level='DEBUG',
        noauth_local_webserver='true')

    youtube = get_authenticated_service(args)
    try:
        initialize_upload(youtube, args)
    except HttpError as e:
        print("An HTTP error %d occurred:\n%s" % (e.resp.status, e.content))
Esempio n. 7
0
path = 'F:/TEMP_C/'

print("Starting YouTube upload from TEMP_C..") 

count = 0
while (count < 1):
	for file in os.listdir(path):
			if file.endswith(".mp4"): #Only uploads MP4 files
				fullName=path + file
				print file
				print("Searching in TEMP_C...")
				#The following is the metadata that is added to the uploaded file. Everything stays the same except the filename.
				title = file
				description = ("SUBSCRIBE: http://bit.ly/Oqg3iE\n\nThe Atlantic Coast Conference (ACC) is a collegiate athletic conference in the United States in which its fifteen member universities compete in the National Collegiate Athletic Association (NCAA's) Division I, with its football teams competing in the Football Bowl Subdivision (FBS), the highest levels for athletic competition in US-based collegiate sports. The ACC sponsors competition in twenty-five sports with many of its member institutions' athletic programs held in high regard nationally. ACC teams and athletes have claimed dozens of national championships in multiple sports throughout the conference's history. Generally, the ACC's top athletes and teams in any particular sport in a given year are considered to be among the top collegiate competitors in the nation. The ACC is considered to be one of the six collegiate power conferences, all of which enjoy extensive media coverage and automatic qualifying for their football champion into the Bowl Championship Series (BCS). With the advent of the College Football Playoff in 2014, the ACC will be one of five conferences with a contractual tie-in to an \"access bowl\", the successors to the BCS. \n\nFounded in 1953 in Greensboro, North Carolina, by seven universities located in the South Atlantic States, the conference added additional members in late 1953, 1979, 1991, 2004, and 2013. The 2004 and 2013 additions extended the conference's footprint into the Northeast and Midwest. The most recent expansion in 2013 saw the additions of the University of Notre Dame, the University of Pittsburgh, and Syracuse University. In 2012, the University of Maryland's Board of Regents voted to withdraw from the ACC to join the Big Ten Conference. On November 28, 2012, the ACC's Council of Presidents voted unanimously to invite the University of Louisville as a full member, replacing Maryland.\n\nConnect with the ACCDigitalNetwork Online:\nVisit the ACC WEBSITE: http://theacc.com\nFollow the ACCDN on Twitter: https://twitter.com/theACCDN\nFollow the ACCDN on Instagram: http://instagram.com/theACCDN\n\nhttp://www.youtube.com/user/ACCDigitalNetwork")
				keywords = ["ACCDigitalNetwork, ACC Digital Network, ACCDN, ACC, College Sports, Division I, NCAA, Atlantic Coast Conference, athletics, competition, Ruby Tuesday"]
				category="17"
				privacyStatus="private"
				options=fullName, title, description, keywords, category, privacyStatus
				args = argparser.parse_args()
				youtube = get_authenticated_service(args)
				try:
					initialize_upload(youtube, options)
				except HttpError, e:
					print "An HTTP error %d occurred:\n%s" % (e.resp.status, e.content)
				os.remove(fullName)
				print "Complete"
			else:
				print "Either file is missing or is not readable"
	
	
print "Stopped"