示例#1
0
class MusicbrainzArtist(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField()
    country = WhamCharField(max_length=255, null=True)


    class WhamMeta(MusicbrainzMeta):
        endpoint = 'artist/'

    class Meta:
        db_table = 'musicbrainz_artist'

    def __unicode__(self):
        return self.name
示例#2
0
class LastFmUser(WhamModel):

    name = WhamCharField(max_length=255, primary_key=True)

    top_artists = WhamManyToManyField(
        #http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=rj&api_key=a04961fe4330211ff149a949dfabef51&format=json
        'LastFmArtist',
        through='LastFmUserTopArtists',
        wham_endpoint='',
        wham_pk_param='user',
        wham_params={'method': 'user.gettopartists'},
        wham_results_path=('topartists', 'artist'))

    class Meta:
        db_table = 'lastfm_user'

    class WhamMeta(LastFmMeta):
        endpoint = ''
        detail_base_result_path = ('user', )
        params = {'method': 'user.getInfo'}
        url_pk_type = 'querystring'
        url_pk_param = 'user'

    def __unicode__(self):
        return self.name
示例#3
0
class SpotifyTrack(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField()

    href = WhamTextField(null=True)
    popularity = WhamIntegerField(null=True)
    track_number = WhamIntegerField(null=True)
    uri = WhamTextField(null=True)
    type = WhamTextField(null=True)
    preview_url = WhamTextField(null=True)
    artists = WhamManyToManyField('SpotifyArtist', related_name='tracks')

    class WhamMeta(SpotifyMeta):
        endpoint = 'tracks'

        class Search:
            endpoint = 'search'
            params = {'type': 'track'}
            results_path = ('tracks', 'items')

    class Meta:
        db_table = 'spotify_track'

    def __unicode__(self):
        return self.name
示例#4
0
class InstagramPost(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)

    type = WhamCharField(max_length=10)
    image_url = WhamImageUrlField(wham_result_path=('images',
                                                    'standard_resolution',
                                                    'url'))

    class Meta:
        db_table = 'instagram_media'

    class WhamMeta(InstagramMeta):
        class Search:
            endpoint = 'tags/{{tag}}/media/recent'
            results_path = ('data', )
            fields = ('tag', )

    def __unicode__(self):
        return self.image_url
示例#5
0
class ProgrammingLanguage(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField(wham_result_path=('property', '/type/object/name',
                                           'values', 0, 'value'))

    # language_designers = models.ManyToManyField('Person')

    class WhamMeta(FreebaseMeta):
        endpoint = 'topic'

    def __unicode__(self):
        return self.name
示例#6
0
class FacebookUser(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    username = WhamTextField(unique=True)
    name = WhamTextField()
    gender = WhamTextField()
    first_name = WhamTextField()
    last_name = WhamTextField()

    class Meta:
        db_table = 'facebook_user'

    class WhamMeta(FacebookMeta):
        endpoint = ''

    def __unicode__(self):
        return self.name
示例#7
0
class DeezerTrack(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    title = WhamTextField(
    )  #TODO: this shouldn't be required if json property is same as django fieldname

    rank = WhamIntegerField(null=True)
    bpm = WhamFloatField(null=True)
    track_position = WhamIntegerField(null=True)

    # examples:
    # id: 3135556,
    # readable: true,
    # title: "Harder Better Faster Stronger",
    # isrc: "GBDUW0000059",
    # link: "http://www.deezer.com/track/3135556",
    # duration: 225,
    # track_position: 4,
    # disk_number: 1,
    # rank: 757802,
    # explicit_lyrics: false,
    # preview: "http://cdn-preview-5.deezer.com/stream/51afcde9f56a132096c0496cc95eb24b-3.mp3",
    # bpm: 123.5,
    # gain: -6.48,
    # available_countries: [],
    # artist: {},
    # album: {},
    # type: "track"

    class Meta:
        db_table = 'deezer_track'

    class WhamMeta(DeezerMeta):
        endpoint = 'track'

        # does not currently work as Wham search is currently limited to name__icontains #TODO
        # class Search:
        #     endpoint = 'search/track'
        #     results_path = ('data',)
        #     fields = ('title',) #actually only uses one for now

    def __unicode__(self):
        return self.title
示例#8
0
class FreebaseMusicbrainzArtist(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField(wham_result_path=('property', '/type/object/name',
                                           'values', 0, 'value'))
    origin_text = WhamTextField(wham_result_path=('property',
                                                  '/music/artist/origin',
                                                  'values', 0, 'text'))
    place_of_birth = WhamTextField(
        wham_result_path=('property', '/people/person/place_of_birth',
                          'values', 0, 'text'))

    class WhamMeta(FreebaseMeta):
        endpoint = 'topic/authority/musicbrainz/artist'


# country/place for band is in:
#   /music/artist/origin
# country/place for solo performer is

#/people/person/place_of_birth

# also of use (solo artist)
# /music/artist/active_end: {},
# /music/artist/active_start: {},
# /music/artist/album: {},
# /music/artist/contribution: {},
# /music/artist/genre: {},
# /music/artist/track: {},
# /music/artist/track_contributions: {},

#(band stuff)
# /music/artist/active_end: {},
# /music/artist/active_start: {},
# /music/artist/album: {},
# /music/artist/concert_tours: {},
# /music/artist/genre: {},
# /music/artist/home_page: {},
# /music/artist/label: {},
# /music/artist/origin: {},
# /music/artist/track: {},
# /music/musical_group/member: {},
示例#9
0
class LastFmArtist(WhamModel):

    name = WhamTextField(primary_key=True)

    mbid = WhamCharField(
        max_length=255, null=True, wham_can_lookup=True
    )  #this *would* be unique & not nullable, but lasfm doesn't always know it

    class Meta:
        db_table = 'lastfm_artist'

    class WhamMeta(LastFmMeta):
        endpoint = ''
        params = {'method': 'artist.getInfo'}
        detail_base_result_path = ('artist', )
        url_pk_type = 'querystring'
        url_pk_param = 'artist'

    def __unicode__(self):
        return self.name
示例#10
0
class InstagramTag(WhamModel):

    name = WhamCharField(max_length=255, primary_key=True)

    posts = WhamManyToManyField(
        #  https://api.instagram.com/v1/tags/djangocon/media/recent
        'InstagramPost',
        related_name='tags',
        wham_endpoint='tags/{{id}}/media/recent',
        wham_results_path=('data', ))

    class Meta:
        db_table = 'instagram_tag'

    class WhamMeta(InstagramMeta):
        endpoint = 'tags'
        detail_base_result_path = ('data', )  #can we make this less verbose??

    def __unicode__(self):
        return self.name
示例#11
0
class SpotifyArtist(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField()

    href = WhamTextField(null=True)
    popularity = WhamIntegerField(null=True)
    uri = WhamTextField(null=True)

    albums = WhamManyToManyField(
        'SpotifyAlbum',
        related_name='artists',
        wham_endpoint='artists/{{id}}/albums',
        wham_results_path=('items',)
    )

    # TODO:
    # tracks = WhamManyToManyField(
    #     'SpotifyTrack',
    #     # related_name='artists',
    #     wham_endpoint='artists/{{id}}/albums',
    #     wham_results_path=('items',)
    # )

    class Meta:
        db_table = 'spotify_artist'

    class WhamMeta(SpotifyMeta):
        endpoint = 'artists'

        # i reckon this stuff should really be in Manager, as it has more to do with filter()
        # which is a Manager method

        class Search:
            endpoint = 'search'
            params = {'type': 'artist'}
            results_path = ('artists', 'items')

    def __unicode__(self):
        return self.name
示例#12
0
class SpotifyAlbum(WhamModel):

    # objects = WhamManager()

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField()

    release_date = WhamTextField(null=True)
    popularity = WhamIntegerField(null=True, wham_detailed=True)

    class Meta:
        db_table = 'spotify_album'

    class WhamMeta(SpotifyMeta):
        endpoint = 'albums'
        # search_endpoint = 'search'
        # search_extra_params = {'type': 'album'}
        # search_results_path = ('albums', 'items')


    def __unicode__(self):
        return self.name
示例#13
0
class EventbriteVenue(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField()
    latitude = WhamFloatField()
    longitude = WhamFloatField()

    city = WhamTextField(wham_result_path=('address', 'city'), null=True)
    country = WhamTextField(wham_result_path=('address', 'country'), null=True)
    region = WhamTextField(wham_result_path=('address', 'region'), null=True)
    address_1 = WhamTextField(wham_result_path=('address', 'address_1'),
                              null=True)
    address_2 = WhamTextField(wham_result_path=('address', 'address_2'),
                              null=True)
    country_name = WhamTextField(wham_result_path=('address', 'country_name'),
                                 null=True)

    class Meta:
        db_table = 'eventbrite_venue'

    def __unicode__(self):
        return self.name
示例#14
0
class EventbriteEvent(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)
    name = WhamTextField(wham_result_path=('name', 'text'))
    resource_uri = WhamTextField()
    url = WhamTextField()
    capacity = WhamIntegerField()
    venue = WhamForeignKey(
        EventbriteVenue, null=True
    )  #this should be a foreign key! But we only support m2m so far.

    class WhamMeta(EventbriteMeta):
        endpoint = 'events'

        class Search:
            endpoint = 'events/search'
            results_path = ('events', )

    class Meta:
        db_table = 'eventbrite_event'

    def __unicode__(self):
        return self.name