From 728f3b6e7f906b3e1734e0f8bd7db25ca9bf6bdd Mon Sep 17 00:00:00 2001 From: Nicholas Piper Date: Sun, 14 May 2006 14:25:17 +0000 Subject: Add missing gtkpod.py ; rename playwith_ipod_api.py to use an underscore. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1261 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- bindings/python/examples/Makefile.am | 2 +- bindings/python/examples/play_with_ipod_api.py | 16 +++++ bindings/python/examples/playwith_ipod_api.py | 16 ----- bindings/python/gtkpod.py | 99 ++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 17 deletions(-) create mode 100755 bindings/python/examples/play_with_ipod_api.py delete mode 100755 bindings/python/examples/playwith_ipod_api.py create mode 100644 bindings/python/gtkpod.py diff --git a/bindings/python/examples/Makefile.am b/bindings/python/examples/Makefile.am index 5e6100f..c61802e 100644 --- a/bindings/python/examples/Makefile.am +++ b/bindings/python/examples/Makefile.am @@ -1,4 +1,4 @@ EXTRA_DIST = coverart_fetch.py toy_around.py \ tag_genre_from_audioscrobber.py add_song.py \ - playwith_ipod_api.py create_mp3_tags_from_itdb.py \ + play_with_ipod_api.py create_mp3_tags_from_itdb.py \ play_with_smart_playlists.py diff --git a/bindings/python/examples/play_with_ipod_api.py b/bindings/python/examples/play_with_ipod_api.py new file mode 100755 index 0000000..4780f73 --- /dev/null +++ b/bindings/python/examples/play_with_ipod_api.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +import gpod + +db = gpod.Database() + +print db + +for track in db[4:20]: + print track + print track['title'] + +for pl in db.Playlists: + print pl + for track in pl: + print " ", track diff --git a/bindings/python/examples/playwith_ipod_api.py b/bindings/python/examples/playwith_ipod_api.py deleted file mode 100755 index 4780f73..0000000 --- a/bindings/python/examples/playwith_ipod_api.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python - -import gpod - -db = gpod.Database() - -print db - -for track in db[4:20]: - print track - print track['title'] - -for pl in db.Playlists: - print pl - for track in pl: - print " ", track diff --git a/bindings/python/gtkpod.py b/bindings/python/gtkpod.py new file mode 100644 index 0000000..f9d044a --- /dev/null +++ b/bindings/python/gtkpod.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +import sha +import os +import socket + +# This file is originally stolen from pypod-0.5.0 +# http://superduper.net/index.py?page=pypod +# I hope that's ok, both works are GPL. + +hostname = socket.gethostname() + +class ParseError(Exception): + pass + +class SyncError(Exception): + pass + +def sha1_hash(filename): + import struct + # only hash the first 16k + hash_len = 4*4096 + hash = sha.sha() + size = os.path.getsize(filename) + hash.update(struct.pack("