[Chicago] help code new youtube upload

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


Hey Carl,

I'm sorry it didn't work for you, I wonder what happened. It did work for
me from my local machine, but when I tried from PythonAnywhere so that I
could show you how to work it I couldn't get past the browser session (that
opened in lynx, heh).

Here's what I did on my end:

I first created a virtualenv (I'm using virtualenvwrapper) and installed
googlecl:

    $ mkvirtualenv yt
    $ pip install googlecl

I then tested using a fake video file because I didn't have a video file
immediately available:

    $ touch video.avi
    $ google youtube post --category Education video.avi
    Please specify user: nick271828 at gmail.com
    Please log in and/or grant access via your browser at
https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=4%2FHwuLDEG4C1FWDt2tL9aE7R6Zy2XN&hd=defaultthen
hit enter.
    Loading video.avi
    {'status': 400, 'body': 'No file found in request.', 'reason': 'Bad
Request'}

Since I was working from my local machine, it automatically opened the auth
page in Firefox. After this I went and found a real video file and uploaded
it:

    $ google youtube post Emperor-Sample.avi
    Please specify category: Entertainment
    Loading Emperor-Sample.avi
    Video uploaded:
https://www.youtube.com/watch?v=Y9fJpccXJmI&feature=youtube_gdata

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.

Nick



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

> I hate to be picky, but did you actually run any of the code?
>
> Every single example I find seems to have some setup step missing such
> that the code errors in some way.
>
> I can't even get the interactive browser session stuff to work, which
> would be a step in the right direction.  If I can get everything else
> to work, then I can focus on swapping out how the script does
> authentication.
>
>
> On Fri, Jan 17, 2014 at 11:31 AM, Nick Bennett <nick at goggl.es> wrote:
> > Carl,
> >
> > Take a look at GoogleCL:
> >
> >
> http://webapps.stackexchange.com/questions/11793/how-to-upload-to-youtube-from-the-command-line/40521#40521
> > http://code.google.com/p/googlecl/
> >
> > It may not be exactly what you're looking for since it involves a user
> > consent screen and interactive browser session to get the OAUTH token
> > (though this is required only once per service), but it is pretty snazzy
> > otherwise and simple to install.
> >
> > From the StackExchange answer:
> >
> >    Install via pip:
> >
> >    pip install googlecl
> >
> >    Uploading a video is as simple as:
> >
> >    google youtube post --category Education killer_robots.avi
> >
> >
> > I'll keep digging for a tool that you can supply with app credentials so
> it
> > never requires user interaction. I'd hate to have to go through a user
> > consent page in lynx/w3m if you're in a remote shell.
> >
> >
> > On Thu, Jan 16, 2014 at 2:59 PM, Carl Karsten <carl at personnelware.com>
> > wrote:
> >>
> >> I need help.
> >>
> >> > So seems I should throw out this whole thing and rewrite it using:
> >> > https://developers.google.com/youtube/v3/
> >>
> >> I can't figure out how to run the samples.
> >>
> >> Reading the docs, looking at the sample code, and playing around at
> >> the >>> prompt; I cant figure out how to authenticate.
> >>
> >> Here are the obvious starting places:
> >>
> >> https://developers.google.com/youtube/v3/
> >> https://developers.google.com/api-client-library/python/
> >>
> >> 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
> >>
> >> You will need to get credentials from
> >> https://code.google.com/apis/console/#:access
> >>
> >> If someone can figure out how to setup a test account that isn't
> >> linked to personal accounts so we can share it with random people on
> >> the internet, that woujld be great.
> >>
> >> The milestone I am shooting for:
> >> A single .py that when run will upload an mp4 and print out the youtube
> >> URL.
> >> It should be dirt simple.  All the values should be hard coded, with
> >> the exception of secrets (like password or private key.)
> >>
> >> Here is the same thing that I use to uplaod to the Rackspace CDN:
> >>
> https://github.com/CarlFK/veyepar/blob/master/dj/scripts/rax_uploader.py
> >>
> >> If someone can take a stab at this and tell me how far they got,
> >>
> >> On Mon, Jan 6, 2014 at 4:06 AM, Carl Karsten <carl at personnelware.com>
> >> wrote:
> >> > I would be ecstatic if you used me code!
> >> >
> >> > But..
> >> > This just in, which kinda trows a wrench in my excitement:
> >> >
> >> > My code, youtube_uploader.py is really just a wrapper around
> >> >
> >> > https://developers.google.com/gdata/
> >> >
> >> > so that the rest of the system has a fairly consistent interface to
> >> > various hosts, and I have some simple code to dev/test/debug.
> >> >
> >> > But if you look at the top of the gdata/ url:
> >> > """
> >> > Warning: Most newer Google APIs are not Google Data APIs. The Google
> >> > Data APIs documentation applies only to the older APIs that are listed
> >> > in the Google Data APIs directory. For information about a specific
> >> > new API, see that API's documentation. For information about
> >> > authorizing requests with a newer API, see Google Accounts
> >> > Authentication and Authorization.
> >> > """
> >> >
> >> > So seems I should throw out this whole thing and rewrite it using:
> >> > https://developers.google.com/youtube/v3/
> >> >
> >> > That will be what I put my next effort into, so if you can do
> >> > something with that, it will be more
> >> > helpful.
> >> >
> >> > The interface the rest of the system expects is what you see in
> >> >
> >> > def test_upload():
> >> > and
> >> > def test_set_pub():
> >> >
> >> > Here is where it is used:
> >> >
> >> >
> https://github.com/CarlFK/veyepar/blob/master/dj/scripts/post_yt.py#L153
> >> >
> >> >
> >> >
> https://github.com/CarlFK/veyepar/blob/master/dj/scripts/mk_public.py#L60
> >> >
> >> > yes, pw.py is user/pw
> >> > https://github.com/CarlFK/veyepar/blob/master/dj/scripts/sample_pw.py
> >> >
> >> > And maybe I should to this try/except thing to make it easier:
> >> > like I do here:
> >> >
> >> >
> https://github.com/CarlFK/veyepar/blob/master/dj/scripts/rax_uploader.py#L24
> >> >
> >> > it is 4am.. I need to sleep before my head falls on my keyboard.
> >> > So look for that in a few hours ;)
> >> >
> >> >
> >> > On Sun, Jan 5, 2014 at 8:33 PM, sheila miguez <shekay at pobox.com>
> wrote:
> >> >> I'm +1 for a talk from you.
> >> >>
> >> >> On Jan 5, 2014 8:25 PM, "Nick Bennett" <nick at goggl.es> wrote:
> >> >>>
> >> >>> All that I have learned about Python, I have learned through trial
> and
> >> >>> error in IPython. I usually get the feel of an API or new module
> first
> >> >>> in
> >> >>> the shell, and then I can write code in my editor. I could give a
> talk
> >> >>> on
> >> >>> using an interactive shell to debug code and explore modules, in
> >> >>> particular
> >> >>> IPython but the the approach would be similar with others like IDLE
> or
> >> >>> python or bpython. I introduced my work mentor to it, a purist with
> a
> >> >>> mechanical keyboard tailored for vim use, and since then he has been
> >> >>> using
> >> >>> ipython on most of our Python-based work projects. If that's not a
> >> >>> stunning
> >> >>> recommendation, I don't know what is one.
> >> >>>
> >> >>> Let's call the talk "Getting a feel for the code" and in it I will
> >> >>> talk
> >> >>> about using Python REPL shells including python, IPython, and
> bpython.
> >> >>> I'll
> >> >>> talk about getting access to a Python REPL quickly and easily when
> in
> >> >>> need,
> >> >>> to appeal to a wider audience. Perhaps you see something interesting
> >> >>> on
> >> >>> Github and you want to see how it would work, but you're not a
> >> >>> programmer
> >> >>> yet and/or don't have a Python environment at your fingertips. I'll
> >> >>> talk
> >> >>> about PythonAnywhere, along with a blurb about getting an EC2
> instance
> >> >>> going. Could I use your code, Carl, as an example in the
> presentation?
> >> >>>
> >> >>> Thoughts?
> >> >>>
> >> >>>
> >> >>> On Sun, Jan 5, 2014 at 6:08 PM, Carl Karsten <
> carl at personnelware.com>
> >> >>> wrote:
> >> >>>>
> >> >>>> On Sun, Jan 5, 2014 at 5:48 PM, Nick Bennett <nick at goggl.es>
> wrote:
> >> >>>> > by writing a Python script to get the pairwise distances between
> >> >>>> > Divvy
> >> >>>> > bike
> >> >>>> > stations from the Google Maps API using "by the bike" distances.
> >> >>>>
> >> >>>> I would like something about this.  pretty much anything.
> >> >>>> I use various google API stuff successfully, but it is almost a
> >> >>>> surprise to me that things work.
> >> >>>> and then when they don't work, that is also a surprise.
> >> >>>> I think my main problem is I don't have a clue how to debug this
> >> >>>> stuff, and I don't have a good feel for how to think about it.
> >> >>>>
> >> >>>> Like this code worked for over a year:
> >> >>>>
> >> >>>>
> >> >>>>
> https://github.com/CarlFK/veyepar/blob/master/dj/scripts/youtube_uploader.py#L144
> >> >>>>
> >> >>>> A month or so ago stopped working.  It doesn't error, it just
> doesn't
> >> >>>> give the same results it used to. (it should flip a youtube video
> >> >>>> from
> >> >>>> unlisted to public.) (if anyone wants to hack on this, that one .py
> >> >>>> should run on its own and it should be easy to get the creds setup
> so
> >> >>>> you can test it on your own account, or set up a test account)
> >> >>>>
> >> >>>> I want that fixed, and I want a clue how one goes about figuring
> out
> >> >>>> what is going on.
> >> >>>>
> >> >>>> I have also written code to talk to a goog spread sheet and
> calendar,
> >> >>>> same feeling of uncertainty.
> >> >>>>
> >> >>>> So anything in this area should help.
> >> >>>>
> >> >>>> --
> >> >>>> Carl K
> >> >>>> _______________________________________________
> >> >>>> Chicago mailing list
> >> >>>> Chicago at python.org
> >> >>>> https://mail.python.org/mailman/listinfo/chicago
> >> >>>
> >> >>>
> >> >>>
> >> >>> _______________________________________________
> >> >>> Chicago mailing list
> >> >>> Chicago at python.org
> >> >>> https://mail.python.org/mailman/listinfo/chicago
> >> >>>
> >> >>
> >> >> _______________________________________________
> >> >> Chicago mailing list
> >> >> Chicago at python.org
> >> >> https://mail.python.org/mailman/listinfo/chicago
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Carl K
> >>
> >>
> >>
> >> --
> >> Carl K
> >> _______________________________________________
> >> Chicago mailing list
> >> Chicago at python.org
> >> https://mail.python.org/mailman/listinfo/chicago
> >
> >
> >
> > _______________________________________________
> > 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/b0ac0253/attachment-0001.html>


More information about the Chicago mailing list