diff options
| author | Nicholas Piper <nicholas@users.sourceforge.net> | 2006-04-25 16:56:03 +0000 |
|---|---|---|
| committer | Nicholas Piper <nicholas@users.sourceforge.net> | 2006-04-25 16:56:03 +0000 |
| commit | faef3e315f9ce360ea660aa9179e7865109fab16 (patch) | |
| tree | 742a3ee422ad1490ccdbe84faf4bd1a1b08520f5 /bindings/python/examples | |
| parent | 5447c8e683e1a2e9577237ddb14bd5664bbf725b (diff) | |
| download | libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.tar.gz libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.tar.xz libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.zip | |
Add sw_get_rule() to extract smart playlist rules from GList*, and hopefully improve the guint8,16,32,64 handling
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1249 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'bindings/python/examples')
| -rw-r--r-- | bindings/python/examples/Makefile.am | 3 | ||||
| -rwxr-xr-x | bindings/python/examples/play_with_smart_playlists.py | 55 |
2 files changed, 57 insertions, 1 deletions
diff --git a/bindings/python/examples/Makefile.am b/bindings/python/examples/Makefile.am index 7130527..5e6100f 100644 --- a/bindings/python/examples/Makefile.am +++ b/bindings/python/examples/Makefile.am @@ -1,3 +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 + playwith_ipod_api.py create_mp3_tags_from_itdb.py \ + play_with_smart_playlists.py diff --git a/bindings/python/examples/play_with_smart_playlists.py b/bindings/python/examples/play_with_smart_playlists.py new file mode 100755 index 0000000..3c23ef1 --- /dev/null +++ b/bindings/python/examples/play_with_smart_playlists.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +## Copyright (C) 2006 Nick Piper <nick-gtkpod at nickpiper co uk> +## Part of the gtkpod project. + +## URL: http://www.gtkpod.org/ +## URL: http://gtkpod.sourceforge.net/ + +## The code contained in this file is free software; you can redistribute +## it and/or modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either version +## 2.1 of the License, or (at your option) any later version. + +## This file is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. + +## You should have received a copy of the GNU Lesser General Public +## License along with this code; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +import gpod +import time +from optparse import OptionParser + +parser = OptionParser() +parser.add_option("-m", "--mountpoint", dest="mountpoint", + default="/mnt/ipod", + help="use iPod at MOUNTPOINT", metavar="MOUNTPOINT") +(options, args) = parser.parse_args() + + +itdb = gpod.itdb_parse(options.mountpoint, None) +if not itdb: + print "Failed to read iPod at %s" % options.mountpoint + sys.exit(2) +itdb.mountpoint = options.mountpoint + +for playlist in gpod.sw_get_playlists(itdb): + if playlist.is_spl: + n = gpod.sw_get_list_len(playlist.splrules.rules) + splrules = [gpod.sw_get_rule(playlist.splrules.rules,i) for i in xrange(n)] + print "Playlist: %s" % playlist.name + for i in xrange(gpod.sw_get_list_len(playlist.splrules.rules)): + rule = gpod.sw_get_rule(playlist.splrules.rules, i) + print "| field: %4d action: %4d |" % (rule.field,rule.action) + print "| string: %25s |" % rule.string + print "| fromvalue: %4d fromdate: %4d |" % (rule.fromvalue,rule.fromdate) + print "| fromunits: %4d |" % rule.fromunits + print "Contains:" + for track in gpod.sw_get_playlist_tracks(playlist): + print track.title, track.artist, time.strftime("%c", + time.localtime(track.time_added - 2082844800)) |
