[Chicago] help code new youtube upload

Nick Bennett nick at goggl.es
Fri Jan 17 21:22:21 CET 2014


Carl,

I found their repo wanting (no requirements.txt file in a Python project,
seriously?) so I forked it and added a requirements file and got it to work
for me using *upload_video.py*. I'm still having a bit of trouble with
simple_upload.py, but that sends me down another rabbit hole.

https://github.com/tothebeat/yt-samples-python

I created a README too (there wasn't one of those in the original repo,
sweet), which I'll reproduce here so you don't have to go clicking through
links. Try this out and let me know if you're successful at uploading as I
was. I still got deprecation warnings, only about using
oauth2client.tools.run() and the gflags library. Even the new hotness is
old, I guess.

Nick


# Quickstart

First, clone this repo!

```bash
git clone https://github.com/tothebeat/yt-samples-python.git
```

Install [virtualenvwrapper][2] and its prerequisites. Then run:

```bash
mkvirtualenv yt-samples-python
pip install -r requirements.txt
```

Download your application's client secrets JSON file from the [Google
Developers Console][1] and save to this folder as `client_secrets.json`. If
you do not add this file, you will see something like

```
$ python upload_video.py --file=Emperor-Sample.avi

WARNING: Please configure OAuth 2.0

To make this sample run you will need to populate the client_secrets.json
file
found at:

   /home/nick/src/youtube-upload/yt-samples-python/client_secrets.json

with information from the APIs Console
https://code.google.com/apis/console#access

For more information about the client_secrets.json file format, please
visit:
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
```

When creating the Client ID in the Google Developers Console, be sure to
choose "Installed application" at the prompt for Application Type. Instead
of moving the `client_secrets.json` file to this folder, try putting it
somewhere safe and create a symlink to it:

    $ mkdir ~/.secrets
    $ mv ~/Downloads/downloaded_client_secrets_asdfh234g43trg234tr2gf2.json
~/.secrets/client_secrets.json
    $ ln -s ~/.secrets/client_secrets.json
~/src/yt-samples-python/client_secrets.json

You may also need to change the Product name to something other than the
default under the "Consent screen" section of the APIs & Auth settings in
the Google Developers Console.


# Upload a Video to YouTube

```
python upload_video.py --file=Emperor-Sample.avi
```

If successful, you will see something like this:

```
$ python upload_video.py --file=Emperor-Sample.avi
WARNING:root:This function, oauth2client.tools.run(), and the use of the
gflags library are deprecated and will be removed in a future version of
the library.
Your browser has been opened to visit:

   <URL REDACTED>

If your browser is on a different machine then exit and re-run
this application with the command-line parameter

  --noauth_local_webserver

Authentication successful.
Uploading file...
'Test Title' (video id: <REDACTED>) was successfully uploaded.
```

  [1]: https://cloud.google.com/console
  [2]: http://virtualenvwrapper.readthedocs.org/en/latest/



On Fri, Jan 17, 2014 at 1:29 PM, Carl Karsten <carl at personnelware.com>wrote:

> skay: good catch.
>
> Nick: you have the right idea.  Some little demo that shows something
> actually works.  That is what I am trying to achieve before I start
> wrapping it in the abstraction my video processing expects.
>
> The two samples I am failing to get to work:
>
> https://code.google.com/p/youtube-api-samples/source/browse/samples/python/upload_video.py
> https://github.com/youtube/yt-samples-python/blob/master/simple_upload.py
>
> See if you can use your authentication credentials with those.
>
> There is a good chance I am failing because I am trying to use a
> different accounts to process videos and read my personal email.
>
> Or I am just blundering putting the right strings in the right file in
> the right directory or something stupid like that.
>
>
>
> On Fri, Jan 17, 2014 at 1:06 PM, sheila miguez <shekay at pobox.com> wrote:
> >
> > On Fri, Jan 17, 2014 at 12:46 PM, Nick Bennett <nick at goggl.es> wrote:
> >>
> >> In any case, perhaps this is not the tool you're looking for. This is a
> >> swiss army knife of gdata tools but you just want a simple youtube
> scalpel
> >> that's really sharp.
> >
> >
> > It's the gdata thing that is a problem. They seem to be discouraging use
> of
> > the gdata package and pointing people towards the new goodness.
> >
> >
> > --
> > sheila
> >
> > _______________________________________________
> > Chicago mailing list
> > Chicago at python.org
> > https://mail.python.org/mailman/listinfo/chicago
> >
>
>
>
> --
> Carl K
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20140117/4ec43279/attachment.html>


More information about the Chicago mailing list