예제 #1
0
	sys.exit(1)

if len(sys.argv) > 2:
	artistResults = [artistResults[int(sys.argv[2])]]
else:
	artistResults = [artistResults[0]]
	
tracks_ids = []
for result in artistResults:
	artist_name = result.artist
	releases = []
	for rtype in [m.Release.TYPE_ALBUM, m.Release.TYPE_SINGLE, m.Release.TYPE_COMPILATION, m.Release.TYPE_REMIX]:
		artist = q.getArtistById(artist_name.id, ArtistIncludes(
				releases=(m.Release.TYPE_OFFICIAL, rtype),
				tags=True))
	
		releases.extend(artist.getReleases())

	for release in releases:
		sleep(1) # respect TOS
		release = q.getReleaseById(release.id, ReleaseIncludes(artist = True, tracks = True))
		for track in release.tracks:
			name = track.artist.name if track.artist else release.artist.name
			full_title = (name + u" — " + track.title).lower()
			if not full_title in tracks_ids:
				print name, track.title
				if not sys.stdout.isatty():
					print >> sys.stderr, full_title
				tracks_ids.append(full_title)
		sys.stdout.flush()
예제 #2
0
	def testReleaseEvents(self):
		inc = ReleaseIncludes(labels=True);
		tags = inc.createIncludeTags()
		tags.sort()
		self.assertEqual(tags, ['labels', 'release-events'])
예제 #3
0
	def testIsrcs(self):
		inc = ReleaseIncludes(isrcs=True);
		tags = inc.createIncludeTags()
		tags.sort()
		self.assertEqual(tags, ['isrcs', 'tracks'])
예제 #4
0
 def get_release(self, gid):
     q = Query(self.ws)
     inc = ReleaseIncludes(tracks=True, isrcs=True)
     return q.getReleaseById(gid, include=inc)
예제 #5
0
	def testReleaseGroup(self):
		inc = ReleaseIncludes(releaseGroup=True)
		tags = inc.createIncludeTags()
		self.assertEqual(tags, ['release-groups'])
예제 #6
0
    def __init__(self, releaseId):
        #self.ignoreMissing(True)
        super(MusicBrainz2AlbumInfo, self).__init__()
        if isinstance(releaseId, basestring):
            self.__releaseId = releaseId
            query = Query()
            include = ReleaseIncludes(artist=True, tracks=True,
                    releaseEvents=True)
            release = query.getReleaseById(releaseId, include)
        elif isinstance(releaseId, Release):
            release = releaseId
            self.__releaseId = release.id
        else:
            raise Exception(
                    "incorrect type parameter for MusicBrainz2AlbumInfo %s"
                    % releaseId)

        self.title = release.title
        # XXX: musicbrainz doesn't have genre info. what to do?
        #self.genre = 'Musicbrainz'
        self.artist = release.artist.name
        date = release.getEarliestReleaseDate()
        if not date:
            self.year = 0
        else:
            self.year = int(date[0:4])
        self.genre = ''
        tracks = []
        number = 0
        self.isVarious = False
        for track in release.tracks:
            number += 1
            # XXX: get rid of the overcomplicated validation scheme that makes
            # for these ugly hacks
            class MBTrackInfo(TrackInfo):
                '''Represent musicbrainz track information.'''
                def getPlayLength(self):
                    'getter'
                    return self.__playLength
                def setPlayLength(self, playLength):
                    'setter'
                    self.__playLength = playLength
                def __init__(self):
                    super(MBTrackInfo, self).__init__()
                playLength = property(getPlayLength, setPlayLength)

            track_info = MBTrackInfo()
            del track_info.validateProps[
                    track_info.validateProps.index('playLength')]
            track_info.number = number
            if track.duration:
                track_info.playLength = track.duration / 1000.0
            else:
                # XXX: make sure we don't use namebinder relying on track length
                track_info.playLength = 0
            if track.artist:
                track_info.artist = track.artist.name
                self.isVarious = True
            else:
                track_info.artist = release.artist.name
            track_info.title = track.title
            tracks.append(track_info)
        self.tracks = tracks