コード例 #1
0
ファイル: song.py プロジェクト: rmcauley/rainwave
    def to_dict(self, user=None):
        d = {}
        d["title"] = self.data["title"]
        d["id"] = self.id
        d["rating"] = round(self.data["rating"], 1)
        d["origin_sid"] = self.data["origin_sid"]
        d["link_text"] = self.data["link_text"]
        d["artist_parseable"] = self.data["artist_parseable"]
        d["cool"] = self.data["cool"]
        d["url"] = self.data["url"]
        d["elec_blocked"] = self.data["elec_blocked"]
        d["elec_blocked_by"] = self.data["elec_blocked_by"]
        d["length"] = self.data["length"]

        d["artists"] = []
        d["albums"] = []
        d["groups"] = []
        if self.albums:
            for metadata in self.albums:
                d["albums"].append(metadata.to_dict(user))
        if self.artists:
            for metadata in self.artists:
                d["artists"].append(metadata.to_dict(user))
        if self.groups:
            for metadata in self.groups:
                d["groups"].append(metadata.to_dict(user))

        d["rating_user"] = None
        d["fave"] = None
        d["rating_allowed"] = self.data["rating_allowed"]
        if user:
            d.update(rating.get_song_rating(self.id, user.id))
            if user.data["rate_anything"]:
                d["rating_allowed"] = True

        for v in [
            "entry_id",
            "elec_request_user_id",
            "entry_position",
            "entry_type",
            "entry_votes",
            "elec_request_username",
            "sid",
            "one_up_used",
            "one_up_queued",
            "one_up_id",
            "rating_rank",
            "request_rank",
            "request_count",
            "rating_histogram",
            "rating_count",
            "rating_rank_percentile",
            "request_rank_percentile",
        ]:
            if v in self.data:
                d[v] = self.data[v]

        return d
コード例 #2
0
    def to_dict(self, user=None):
        d = {}
        d['title'] = self.data['title']
        d['id'] = self.id
        d['rating'] = round(self.data['rating'], 1)
        d['origin_sid'] = self.data['origin_sid']
        d['link_text'] = self.data['link_text']
        d['artist_parseable'] = self.data['artist_parseable']
        d['cool'] = self.data['cool']
        d['url'] = self.data['url']
        d['elec_blocked'] = self.data['elec_blocked']
        d['elec_blocked_by'] = self.data['elec_blocked_by']
        d['length'] = self.data['length']
        if 'track_number' in self.data:
            d['track_number'] = self.data['track_number']
        if 'disc_number' in self.data:
            d['disc_number'] = self.data['disc_number']
        if 'year' in self.data:
            d['year'] = self.data['year']

        d['artists'] = []
        d['albums'] = []
        d['groups'] = []
        if self.albums:
            for metadata in self.albums:
                d['albums'].append(metadata.to_dict(user))
        if self.artists:
            for metadata in self.artists:
                d['artists'].append(metadata.to_dict(user))
        if self.groups:
            for metadata in self.groups:
                d['groups'].append(metadata.to_dict(user))

        d['rating_user'] = None
        d['fave'] = None
        d['rating_allowed'] = self.data['rating_allowed']
        if user:
            d.update(rating.get_song_rating(self.id, user.id))
            if user.data['rate_anything']:
                d['rating_allowed'] = True

        for v in [
                "entry_id", "elec_request_user_id", "entry_position",
                "entry_type", "entry_votes", "elec_request_username", "sid",
                "one_up_used", "one_up_queued", "one_up_id", "rating_rank",
                "request_rank", "request_count", "rating_histogram",
                "rating_count", "rating_rank_percentile",
                "request_rank_percentile"
        ]:
            if v in self.data:
                d[v] = self.data[v]

        return d
コード例 #3
0
ファイル: song.py プロジェクト: Siqo53/rainwave
	def to_dict(self, user = None):
		d = {}
		d['title'] = self.data['title']
		d['id'] = self.id
		d['rating'] = self.data['rating']
		d['origin_sid'] = self.data['origin_sid']
		d['link_text'] = self.data['link_text']
		d['artist_parseable'] = self.data['artist_parseable']
		d['cool'] = self.data['cool']
		d['url'] = self.data['url']
		d['elec_blocked'] = self.data['elec_blocked']
		d['elec_blocked_by'] = self.data['elec_blocked_by']
		d['length'] = self.data['length']
		if 'track_number' in self.data:
			d['track_number'] = self.data['track_number']
		if 'disc_number' in self.data:
			d['disc_number'] = self.data['disc_number']
		if 'year' in self.data:
			d['year'] = self.data['year']

		d['artists'] = []
		d['albums'] = []
		d['groups'] = []
		if self.albums:
			for metadata in self.albums:
				d['albums'].append(metadata.to_dict(user))
		if self.artists:
			for metadata in self.artists:
				d['artists'].append(metadata.to_dict(user))
		if self.groups:
			for metadata in self.groups:
				d['groups'].append(metadata.to_dict(user))

		d['rating_user'] = None
		d['fave'] = None
		d['rating_allowed'] = self.data['rating_allowed']
		if user:
			d.update(rating.get_song_rating(self.id, user.id))
			if user.data['rate_anything']:
				d['rating_allowed'] = True

		for v in [ "entry_id", "elec_request_user_id", "entry_position", "entry_type", "entry_votes", "elec_request_username", "sid", "one_up_used", "one_up_queued", "one_up_id", "rating_rank", "request_rank", "request_count", "rating_histogram", "rating_count" ]:
			if v in self.data:
				d[v] = self.data[v]

		return d
コード例 #4
0
ファイル: song.py プロジェクト: RodrigoTjader/rainwave
	def to_dict(self, user = None):
		self.data['id'] = self.id
		self.data['artists'] = []
		self.data['albums'] = []
		self.data['groups'] = []
		if self.albums:
			for metadata in self.albums:
				self.data['albums'].append(metadata.to_dict(user))
		if self.artists:
			for metadata in self.artists:
				self.data['artists'].append(metadata.to_dict(user))
		if self.groups:
			for metadata in self.groups:
				self.data['groups'].append(metadata.to_dict(user))
		self.data['rating_user'] = None
		self.data['fave'] = None
		if user:
			self.data.update(rating.get_song_rating(self.id, user.id))
			if user.data['rate_anything']:
				self.data['rating_allowed'] = True
		return self.data
コード例 #5
0
ファイル: song.py プロジェクト: khakionion/rainwave
	def to_dict(self, user = None):
		self.data['id'] = self.id
		self.data['artists'] = []
		self.data['albums'] = []
		self.data['groups'] = []
		if self.albums:
			for metadata in self.albums:
				self.data['albums'].append(metadata.to_dict(user))
		if self.artists:
			for metadata in self.artists:
				self.data['artists'].append(metadata.to_dict(user))
		if self.groups:
			for metadata in self.groups:
				self.data['groups'].append(metadata.to_dict(user))
		self.data['rating_user'] = None
		self.data['fave'] = None
		if user:
			self.data.update(rating.get_song_rating(self.id, user.id))
			if user.data['rate_anything']:
				self.data['rating_allowed'] = True
		return self.data