Giter Site home page Giter Site logo

pyitunes's Introduction

pyItunes

Created by Liam Kaufman (liamkaufman.com)

Contributions by Liam Kaufman (liamkaufman.com), Steven Miller (copart), dpchu, selftext, z4r, pschorf, Mathew Bramson (mbramson)

Before using pyItunes it is recommended that you backup your Itunes Library XML file. Use pyItunes at your own risk - there is no guarantee that it works or will not blow-up your computer!

Usage:

from pyItunes import *

l = Library("iTunes Music Library.xml")

for id, song in l.songs.items():
	if song.rating > 80:
		print song.name

playlists=l.getPlaylistNames()

for song in l.getPlaylist(playlists[0]).tracks:
	print "[%d] %s - %s" % (song.number, song.artist, song.name)

See below for available song attributes.

There is also a deprecated legacy method, which still works for now:

from pyItunes import *

pl = XMLLibraryParser("iTunes Music Library.xml")
l = Library(pl.dictionary)

for song in l.songs:
	if song.rating > 80:
		print song.name

Notes

Track counts may not match those shown in iTunes. e.g.:

l = Library("iTunes Music Library.xml")
len(l.songs)

May report a higher number than the song count shown in iTunes itself. This is because iTunes does not count things like Podcasts and Voice Memos as "Music," whereas pyitunes counts all tracks.

Version 0.2 adds the ability to get playlists. However, the songs dictionary is keyed on TrackID (as coded in iTunes xml).

Attributes of the Song class:

name (String)
artist (String)
album_artist (String)
composer = None (String)
album = None (String)
genre = None (String)
kind = None (String)
size = None (Integer)
total_time = None (Integer)
track_number = None (Integer)
track_count = None (Integer)
disc_number = None (Integer)
disc_count = None (Integer)
year = None (Integer)
date_modified = None (Time)
date_added = None (Time)
bit_rate = None (Integer)
sample_rate = None (Integer)
comments = None (String)
rating = None (Integer)
album_rating = None (Integer)
play_count = None (Integer)
location = None (String)
compilation = None (Boolean)
grouping = None (String)
lastplayed = None (Time)
length = None (Integer)

Song object attributes can be iterated through like this:

for key,value in SongItem:
	<interact with specific key,value pair>.

You can also convert songs directly to Dictionaries with the ToDict() Method.

SongDictionary = SongItem.ToDict()

pyitunes's People

Contributors

andrenam avatar askedrelic avatar copart avatar dgbc avatar dpchu avatar flolom avatar kerin avatar liamks avatar mbramson avatar pschorf avatar selftext avatar shacker avatar z4r avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.