Using via python script and not command line?

48 views
Skip to first unread message

Angie

unread,
Sep 27, 2013, 2:52:26 PM9/27/13
to googlecl...@googlegroups.com
Hi, I'm trying to code a python script that uploads videos for me when I put them in a certain folder.


So for this I thought Googlecl looked promising but as I'm a python noob I'm having a hard time figuring out how to use googlecl from within another python script.

For instance this is the kind of script I thought might work:

from googelcl import youtube

upload = youtube.post("video.mp4", "Education", "This is a description") # Uploads the video
print upload #prints the youtube URL after upload


But obviously this doesn't work. I've tried looking around the source code but it's all a bit much for me at the moment. I'm still learning and I'll keep trying to figure out the solution on my own after posting this request for help but if anyone could put me in the right direction or help me in any way I'd appreciate it very much, thanks!
Angie

Angie

unread,
Sep 28, 2013, 8:29:04 AM9/28/13
to googlecl...@googlegroups.com

I think I've almost got it. Current code:

from googlecl.youtube.service import YouTubeServiceCL

youtube = YouTubeServiceCL

youtubepost = youtube().post_videos(["path to video file"], "Education", title="Test video", desc="This is a test video ", tags="tag1,tag2,tag3,tag4,tag5")
print youtubepost

But that gives off the error: TypeError: __init__() takes exactly 2 arguments (1 given)

and I can't figure out what the argument I need to give it is, any help?

Tom Miller

unread,
Sep 30, 2013, 8:46:27 AM9/30/13
to googlecl...@googlegroups.com
Hi Angie!

You need to pass a configuration file parser. If you look at the
"main" python file, google.py, the configuration file parser is
created in the "import_service" function, on line 427.

So if you do something like


from googlecl.youtube.service import YouTubeServiceCL
import googlecl.config

config = googlecl.config.load_configuration('path_to_my/config.file')
youtube = YouTubeServiceCL(config)


That should get you a little farther. There's documentation on the
config files here:
https://code.google.com/p/googlecl/source/browse/trunk/README.config,
and the config file uses Python's ConfigParser, so you can read about
that if you want to use a config file. You can probably get away with
passing an empty file as the config file, though.

- Tom
> --
> You received this message because you are subscribed to the Google Groups
> "GoogleCL Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to googlecl-discu...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages