예제 #1
0
	def getSongs(self):
		format = "%Y-%m-%d %H:%M:%S"
		for trackid,attributes in self.il['Tracks'].items():
			s = Song()
			s.name = attributes.get('Name')
			s.track_id = int(attributes.get('Track ID'))
			s.artist = attributes.get('Artist')
			s.album_artist = attributes.get('Album Artist')
			s.composer = attributes.get('Composer')
			s.album = attributes.get('Album')
			s.genre = attributes.get('Genre')
			s.kind = attributes.get('Kind')
			if attributes.get('Size'):
				s.size = int(attributes.get('Size'))
			s.total_time = attributes.get('Total Time')
			s.track_number = attributes.get('Track Number')
			if attributes.get('Track Count'):
				s.track_count = int(attributes.get('Track Count'))
			if attributes.get('Disc Number'):
				s.disc_number = int(attributes.get('Disc Number'))
			if attributes.get('Disc Count'):
				s.disc_count = int(attributes.get('Disc Count'))
			if attributes.get('Year'):
				s.year = int(attributes.get('Year'))
			if attributes.get('Date Modified'):
				s.date_modified = time.strptime(str(attributes.get('Date Modified')),format)
			if attributes.get('Date Added'):
				s.date_added = time.strptime(str(attributes.get('Date Added')),format)
			if attributes.get('Bit Rate'):
				s.bit_rate = int(attributes.get('Bit Rate'))
			if attributes.get('Sample Rate'):
				s.sample_rate = int(attributes.get('Sample Rate'))
			s.comments = attributes.get("Comments")
			if attributes.get('Rating'):
				s.rating = int(attributes.get('Rating'))
			if attributes.get('Play Count'):
				s.play_count = int(attributes.get('Play Count'))
			if attributes.get('Location'):
				s.location = attributes.get('Location')
				s.location = urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:])
				s.location = s.location.decode('utf-8') if PY2 else s.location # fixes bug #19
				if ( self.musicPathXML is not None and self.musicPathSystem is not None ):
					s.location = s.location.replace(self.musicPathXML,self.musicPathSystem)
			s.compilation = 'Compilation' in attributes
			if attributes.get('Play Date UTC'):
				s.lastplayed = time.strptime(str(attributes.get('Play Date UTC')),format)
			if attributes.get('Skip Count'):
				s.skip_count = int(attributes.get('Skip Count'))
			if attributes.get('Skip Date'):
				s.skip_date = time.strptime(str(attributes.get('Skip Date')),format)
			if attributes.get('Total Time'):
				s.length = int(attributes.get('Total Time'))
			if attributes.get('Grouping'):
				s.grouping = attributes.get('Grouping')
			if self.filesOnly==True and attributes.get('Track Type') == 'File':
				if self.legacymode:
					self.songs.append(s)
				else:
					self.songs[int(trackid)] = s
			elif self.filesOnly==False:
				if self.legacymode:
					self.songs.append(s)
				else:
					self.songs[int(trackid)] = s
예제 #2
0
	def getSongs(self):
		format = "%Y-%m-%d %H:%M:%S"
		for trackid,attributes in self.il['Tracks'].iteritems():
			s = Song()
			s.name = attributes.get('Name')
			s.artist = attributes.get('Artist')
			s.album_artist = attributes.get('Album Artist')
			s.composer = attributes.get('Composer')
			s.album = attributes.get('Album')
			s.genre = attributes.get('Genre')
			s.kind = attributes.get('Kind')
			if attributes.get('Size'):
				s.size = int(attributes.get('Size'))
			s.total_time = attributes.get('Total Time')
			s.track_number = attributes.get('Track Number')
			if attributes.get('Track Count'):
				s.track_count = int(attributes.get('Track Count'))
			if attributes.get('Disc Number'):
				s.disc_number = int(attributes.get('Disc Number'))
			if attributes.get('Disc Count'):
				s.disc_count = int(attributes.get('Disc Count'))
			if attributes.get('Year'):
				s.year = int(attributes.get('Year'))
			if attributes.get('Date Modified'):
				s.date_modified = time.strptime(str(attributes.get('Date Modified')),format)
			if attributes.get('Date Added'):
				s.date_added = time.strptime(str(attributes.get('Date Added')),format)
			if attributes.get('Bit Rate'):
				s.bit_rate = int(attributes.get('Bit Rate'))
			if attributes.get('Sample Rate'):
				s.sample_rate = int(attributes.get('Sample Rate'))
			s.comments = attributes.get("Comments	")
			if attributes.get('Rating'):
				s.rating = int(attributes.get('Rating'))
			if attributes.get('Play Count'):
				s.play_count = int(attributes.get('Play Count'))
			if attributes.get('Location'):
				if ( self.musicPathXML is None or self.musicPathSystem is None ):
					s.location = unicode(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]),"utf8")
				else:
					s.location = unicode(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]).replace(self.musicPathXML,self.musicPathSystem),"utf8")
			s.compilation = 'Compilation' in attributes
			if attributes.get('Play Date UTC'):
				s.lastplayed = time.strptime(str(attributes.get('Play Date UTC')),format)
			if attributes.get('Total Time'):
				s.length = int(attributes.get('Total Time'))
			if attributes.get('Grouping'):
				s.grouping = attributes.get('Grouping')
			if self.legacymode:
				self.songs.append(s)
			else:
				self.songs[int(trackid)] = s
예제 #3
0
파일: Library.py 프로젝트: codyzu/pyitunes
	def getSongs(self):
		format = "%Y-%m-%d %H:%M:%S"
		for trackid,attributes in self.il['Tracks'].items():
			s = Song()
			s.name = attributes.get('Name')
			s.artist = attributes.get('Artist')
			s.album_artist = attributes.get('Album Artist')
			s.composer = attributes.get('Composer')
			s.album = attributes.get('Album')
			s.genre = attributes.get('Genre')
			s.kind = attributes.get('Kind')
			if attributes.get('Size'):
				s.size = int(attributes.get('Size'))
			s.total_time = attributes.get('Total Time')
			s.track_number = attributes.get('Track Number')
			if attributes.get('Track Count'):
				s.track_count = int(attributes.get('Track Count'))
			if attributes.get('Disc Number'):
				s.disc_number = int(attributes.get('Disc Number'))
			if attributes.get('Disc Count'):
				s.disc_count = int(attributes.get('Disc Count'))
			if attributes.get('Year'):
				s.year = int(attributes.get('Year'))
			if attributes.get('Date Modified'):
				s.date_modified = time.strptime(str(attributes.get('Date Modified')),format)
			if attributes.get('Date Added'):
				s.date_added = time.strptime(str(attributes.get('Date Added')),format)
			if attributes.get('Bit Rate'):
				s.bit_rate = int(attributes.get('Bit Rate'))
			if attributes.get('Sample Rate'):
				s.sample_rate = int(attributes.get('Sample Rate'))
			s.comments = attributes.get("Comments	")
			if attributes.get('Rating'):
				s.rating = int(attributes.get('Rating'))
			if attributes.get('Play Count'):
				s.play_count = int(attributes.get('Play Count'))
			if attributes.get('Location'):
				if ( self.musicPathXML is None or self.musicPathSystem is None ):
					# s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]),"utf8")
					s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]))
				else:
					# s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]).replace(self.musicPathXML,self.musicPathSystem),"utf8")
					s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]).replace(self.musicPathXML,self.musicPathSystem))
			s.compilation = 'Compilation' in attributes
			if attributes.get('Play Date UTC'):
				s.lastplayed = time.strptime(str(attributes.get('Play Date UTC')),format)
			if attributes.get('Total Time'):
				s.length = int(attributes.get('Total Time'))
			if attributes.get('Grouping'):
				s.grouping = attributes.get('Grouping')
			if self.filesOnly==True and attributes.get('Track Type') == 'File':
				if self.legacymode:
					self.songs.append(s)
				else:
					self.songs[int(trackid)] = s
			elif self.filesOnly==False:
				if self.legacymode:
					self.songs.append(s)
				else:
					self.songs[int(trackid)] = s
예제 #4
0
파일: Library.py 프로젝트: mjama/pyitunes
	def parseDictionary(self,dictionary):
		songs = []
		format = "%Y-%m-%dT%H:%M:%SZ"
		for song,attributes in dictionary.iteritems():
			s = Song()
			s.name = attributes.get('Name')
			s.artist = attributes.get('Artist')
			s.album_artist = attributes.get('Album Aritst')
			s.composer = attributes.get('Composer')
			s.album = attributes.get('Album')
			s.genre = attributes.get('Genre')
			s.kind = attributes.get('Kind')
			if attributes.get('Size'):
				s.size = int(attributes.get('Size'))
			s.total_time = attributes.get('Total Time')
			s.track_number = attributes.get('Track Number')
			if attributes.get('Year'):
				s.year = int(attributes.get('Year'))
			if attributes.get('Date Modified'):
				s.date_modified = time.strptime(attributes.get('Date Modified'),format)
			if attributes.get('Date Added'):
				s.date_added = time.strptime(attributes.get('Date Added'),format)
			if attributes.get('Bit Rate'):
				s.bit_rate = int(attributes.get('Bit Rate'))
			if attributes.get('Sample Rate'):
				s.sample_rate = int(attributes.get('Sample Rate'))
			s.comments = attributes.get("Comments	")
			if attributes.get('Rating'):
				s.rating = int(attributes.get('Rating'))
			if attributes.get('Play Count'):
				s.play_count = int(attributes.get('Play Count'))
			if attributes.get('Location'):
				s.location = attributes.get('Location')			
			songs.append(s)
			s.compilation = 'Compilation' in attributes
		return songs
예제 #5
0
	def parseDictionary(self,dictionary):
		songs = []
		format = "%Y-%m-%dT%H:%M:%SZ"
		for song,attributes in dictionary.iteritems():
			s = Song()
			s.name = attributes.get('Name')
			s.artist = attributes.get('Artist')
			s.album_artist = attributes.get('Album Artist')
			s.composer = attributes.get('Composer')
			s.album = attributes.get('Album')
			s.genre = attributes.get('Genre')
			s.kind = attributes.get('Kind')
			if attributes.get('Size'):
				s.size = int(attributes.get('Size'))
			s.total_time = attributes.get('Total Time')
			s.track_number = attributes.get('Track Number')
			if attributes.get('Year'):
				s.year = int(attributes.get('Year'))
			if attributes.get('Date Modified'):
				s.date_modified = time.strptime(attributes.get('Date Modified'),format)
			if attributes.get('Date Added'):
				s.date_added = time.strptime(attributes.get('Date Added'),format)
			if attributes.get('Bit Rate'):
				s.bit_rate = int(attributes.get('Bit Rate'))
			if attributes.get('Sample Rate'):
				s.sample_rate = int(attributes.get('Sample Rate'))
			s.comments = attributes.get("Comments	")
			if attributes.get('Rating'):
				s.rating = int(attributes.get('Rating'))
			if attributes.get('Play Count'):
				s.play_count = int(attributes.get('Play Count'))
			if attributes.get('Location'):
				s.location = attributes.get('Location')			
			songs.append(s)
			s.compilation = 'Compilation' in attributes
		return songs
예제 #6
0
	def _buildSong(self,songId,attributes):
		s = Song()
		s.itunes_id = songId
		s.name = attributes.get('Name')
		s.artist = attributes.get('Artist')
		s.album_artist = attributes.get('Album Aritst')
		s.composer = attributes.get('Composer')
		s.album = attributes.get('Album')
		s.genre = attributes.get('Genre')
		s.kind = attributes.get('Kind')
		if attributes.get('Size'):
			s.size = int(attributes.get('Size'))
		s.total_time = attributes.get('Total Time')
		s.track_number = attributes.get('Track Number')
		if attributes.get('Year'):
			s.year = int(attributes.get('Year'))
		if attributes.get('Date Modified'):
			s.date_modified = time.strptime(attributes.get('Date Modified'),self.TIMESTAMP_FORMAT)
		if attributes.get('Date Added'):
			s.date_added = time.strptime(attributes.get('Date Added'),self.TIMESTAMP_FORMAT)
		if attributes.get('Bit Rate'):
			s.bit_rate = int(attributes.get('Bit Rate'))
		if attributes.get('Sample Rate'):
			s.sample_rate = int(attributes.get('Sample Rate'))
		s.comments = attributes.get("Comments	")
		if attributes.get('Rating'):
			s.rating = int(attributes.get('Rating'))
		if attributes.get('Play Count'):
			s.play_count = int(attributes.get('Play Count'))
		if attributes.get('Location'):
			s.location = attributes.get('Location')

		return s
예제 #7
0
파일: Library.py 프로젝트: codyzu/pyitunes
 def getSongs(self):
     format = "%Y-%m-%d %H:%M:%S"
     for trackid, attributes in self.il["Tracks"].items():
         s = Song()
         s.name = attributes.get("Name")
         s.artist = attributes.get("Artist")
         s.album_artist = attributes.get("Album Artist")
         s.composer = attributes.get("Composer")
         s.album = attributes.get("Album")
         s.genre = attributes.get("Genre")
         s.kind = attributes.get("Kind")
         if attributes.get("Size"):
             s.size = int(attributes.get("Size"))
         s.total_time = attributes.get("Total Time")
         s.track_number = attributes.get("Track Number")
         if attributes.get("Track Count"):
             s.track_count = int(attributes.get("Track Count"))
         if attributes.get("Disc Number"):
             s.disc_number = int(attributes.get("Disc Number"))
         if attributes.get("Disc Count"):
             s.disc_count = int(attributes.get("Disc Count"))
         if attributes.get("Year"):
             s.year = int(attributes.get("Year"))
         if attributes.get("Date Modified"):
             s.date_modified = time.strptime(str(attributes.get("Date Modified")), format)
         if attributes.get("Date Added"):
             s.date_added = time.strptime(str(attributes.get("Date Added")), format)
         if attributes.get("Bit Rate"):
             s.bit_rate = int(attributes.get("Bit Rate"))
         if attributes.get("Sample Rate"):
             s.sample_rate = int(attributes.get("Sample Rate"))
         s.comments = attributes.get("Comments	")
         if attributes.get("Rating"):
             s.rating = int(attributes.get("Rating"))
         if attributes.get("Play Count"):
             s.play_count = int(attributes.get("Play Count"))
         if attributes.get("Location"):
             if self.musicPathXML is None or self.musicPathSystem is None:
                 # s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]),"utf8")
                 s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get("Location")).path[1:]))
             else:
                 # s.location = text_type(urlparse.unquote(urlparse.urlparse(attributes.get('Location')).path[1:]).replace(self.musicPathXML,self.musicPathSystem),"utf8")
                 s.location = text_type(
                     urlparse.unquote(urlparse.urlparse(attributes.get("Location")).path[1:]).replace(
                         self.musicPathXML, self.musicPathSystem
                     )
                 )
         s.compilation = "Compilation" in attributes
         if attributes.get("Play Date UTC"):
             s.lastplayed = time.strptime(str(attributes.get("Play Date UTC")), format)
         if attributes.get("Total Time"):
             s.length = int(attributes.get("Total Time"))
         if attributes.get("Grouping"):
             s.grouping = attributes.get("Grouping")
         if self.filesOnly == True and attributes.get("Track Type") == "File":
             if self.legacymode:
                 self.songs.append(s)
             else:
                 self.songs[int(trackid)] = s
         elif self.filesOnly == False:
             if self.legacymode:
                 self.songs.append(s)
             else:
                 self.songs[int(trackid)] = s