예제 #1
0
    video = api.video_info(video_id)

    return artist_matcher.associate_video_with_artist(artist, _trans_video(video, 'artist-resource-handler:youtube').get_video())

  @classmethod
  def id(self):
    return 'youtube'

class YouTubeMediaExtractor(ArtistMediaExtractor):
  def extract_media(self, artist):
    videos = []
    
    for video in artist.get_videos('youtube'):
      logger.debug('Fetching video information for: %s' % video.media_id)
        
      video = api.video_info(video.media_id)

      videos.append(_trans_video(video, 'media-extractor:youtube-videos'))

    return videos

  @classmethod
  def id(self):
    return 'youtube'

extensions.register_resource_extractor     (YouTubeResourceExtractor)
extensions.register_show_resource_handler  (YouTubeShowResourceHandler)
extensions.register_artist_resource_handler(YouTubeArtistResourceHandler)
extensions.register_media_extractor        (YouTubeMediaExtractor)
예제 #2
0
    protocol, video_id = uri.split(':')

    video = api.video_info(video_id)

    return artist_matcher.associate_video_with_artist(artist, _trans_video(video, 'artist-resource-handler:vimeo').get_video())

  @classmethod
  def id(self):
    return 'vimeo'

class VimeoMediaExtractor(ArtistMediaExtractor):
  def extract_media(self, artist):
    videos = []
    
    for video in artist.get_videos('vimeo'):
      logger.debug('Fetching video information for: %s' % video.media_id)
        
      video = api.video_info(video.media_id)

      videos.append(_trans_video(video, 'media-extractor:vimeo-videos'))

    return videos

  @classmethod
  def id(self):
    return'vimeo'

extensions.register_resource_extractor     (VimeoResourceExtractor)
extensions.register_show_resource_handler  (VimeoShowResourceHandler)
extensions.register_artist_resource_handler(VimeoArtistResourceHandler)
extensions.register_media_extractor        (VimeoMediaExtractor)
예제 #3
0
    
    return artist_matcher.associate_profile_with_matching_artist(show, name, artist_profile)

  @classmethod
  def id(self):
    return 'twitter'

class TwitterArtistResourceHandler(ArtistResourceHandler):
  def supports(self, uri):
    protocol, user_id = uri.split(':')

    return protocol == 'twitter-profile'

  def handle(self, artist, uri):
    protocol, user_id = uri.split(':')

    profile_link = 'http://www.twitter.com/%s' % user_id

    name = parsing.get_name_from_title(profile_link, NAME_RE)

    artist_profile = ArtistProfile(system_id = 'twitter', profile_id = user_id, source_id = 'artist-resource-handler:twitter', url = profile_link)

    return artist_matcher.associate_profile_with_artist(artist, name, artist_profile)

  @classmethod
  def id(self):
    return 'twitter'

extensions.register_resource_extractor     (TwitterResourceExtractor)
extensions.register_show_resource_handler  (TwitterShowResourceHandler)
extensions.register_artist_resource_handler(TwitterArtistResourceHandler)
예제 #4
0
    return ret

class BandCampShowResourceHandler(ShowResourceHandler):
  def supports(self, uri):
    protocol, user_id = uri.split(':')

    return protocol == 'bandcamp-profile'

  def handle(self, show, uri):
    protocol, user_id = uri.split(':')

    logger.debug('Fetching profile information for: %s' % user_id)

    service = BandCampService(API_KEY)

    if user_id.isdigit():
      band = service.get_band_by_id(user_id)
    else:
      band = service.get_band_by_url(user_id)

    artist_profile = ArtistProfile(system_id = SYSTEM_ID, profile_id = str(band.id), source_id = 'show-resource-handler:bandcamp', url = band.url)

    return artist_matcher.associate_profile_with_matching_artist(show, band.name, artist_profile)

  @classmethod
  def id(self):
    return SYSTEM_ID

extensions.register_resource_extractor   (BandCampResourceExtractor)
extensions.register_show_resource_handler(BandCampShowResourceHandler)
예제 #5
0
    return artist_matcher.associate_profile_with_matching_artist(show, name, artist_profile)

  @classmethod
  def id(self):
    return 'muxtape'
    
class MuxtapeArtistResourceHandler(ArtistResourceHandler):
  def supports(self, uri):
    protocol, user_id = uri.split(':')

    return protocol == 'muxtape-profile'

  def handle(self, artist, uri):
    protocol, user_id = uri.split(':')

    profile_link = 'http://%s.muxtape.com/' % user_id

    name = parsing.get_name_from_title(profile_link, NAME_RE)

    artist_profile = ArtistProfile(system_id = 'muxtape', profile_id = user_id, source_id = 'artist-resource-handler:muxtape', url = profile_link)

    return artist_matcher.associate_profile_with_artist(artist, name, artist_profile)

  @classmethod
  def id(self):
    return 'muxtape'

extensions.register_resource_extractor     (MuxtapeResourceExtractor)
extensions.register_show_resource_handler  (MuxtapeShowResourceHandler)
extensions.register_artist_resource_handler(MuxtapeArtistResourceHandler)
예제 #6
0
  
class FacebookShowResourceHandler(ShowResourceHandler):
  def supports(self, uri):
    protocol, user_id = uri.split(':')

    return protocol == 'facebook'

  def handle(self, show, uri):
    protocol, object_id = uri.split(':')
    
    logger.debug('Fetching facebook object: %s' % object_id)
    
    profile        = GraphAPI().get_object(object_id)
    
    logging.debug('Item: %s' % profile)

    # Not all profiles have links
    if 'link' in profile:
      artist_profile = ArtistProfile(system_id = 'facebook', profile_id = profile['id'], source_id = 'show-resource-handler:facebook', url = profile['link'])
    
      return artist_matcher.associate_profile_with_matching_artist(show, profile['name'], artist_profile)
    else:
      return False

  @classmethod
  def id(self):
    return 'facebook'

extensions.register_resource_extractor   (FacebookResourceExtractor)
extensions.register_show_resource_handler(FacebookShowResourceHandler)
예제 #7
0
    else:
      table = None
      
      for item in tr.iterancestors(tag = 'table'):
        table = item
        
        break
        
      resources = self.resource_extractor.extract_resources(doc)
      
      return ArtistProfileParserResult(resources)
      
  def _parse_v2(self, doc):
    content    = parsing.get_first_element(doc, '.content.contentMid')

    html_boxes = list(parsing.get_elements(content, '.htmlBoxModule'))

    resources = self.resource_extractor.extract_resources(*html_boxes)
    
    return ArtistProfileParserResult(resources)

  @classmethod
  def id(self):
    return SYSTEM_ID

extensions.register_resource_extractor     (MySpaceResourceExtractor)
extensions.register_show_resource_handler  (MySpaceShowResourceHandler)
extensions.register_artist_resource_handler(MySpaceArtistResourceHandler)
extensions.register_media_extractor        (MySpaceSongExtractor)
extensions.register_artist_profile_parser  (MyspaceProfileParser)