Example #1
0
def associate_video_with_matching_artist(show, video):
  for artist_info, artist in _artists(show):    
    associate = False

    if video.artist:
      logger.debug('Checking if %s matches video artist %s' % (artist_info.name, video.artist))

      associate = artist_matches(artist_info.name, video.artist) or (artist and artist_matches(artist.name, video.artist))

    if not associate:
      logger.debug('Checking if %s matches video title %s' % (artist_info.name, video.title))

      associate = artist_mentioned(artist_info.name, video.title) or (artist and artist_mentioned(artist.name, video.title))
      
    if associate:
      logger.debug('Video matches artist: %s, associating' % (artist_info.name))

      if not artist:
        artist = get_or_create_artist(artist_info.name)

        artist_info.artist_id = artist.id

      artist.add_video(video)

      artist.save()

      return True

  return False
Example #2
0
def associate_video_with_artist(artist, video):
  associate = False

  if video.artist:
    logger.debug('Checking if %s matches video artist %s' % (artist.name, video.artist))

    associate = artist_matches(artist.name, video.artist)

  if not associate:
    logger.debug('Checking if %s matches video title %s' % (artist.name, video.title))

    associate = artist_mentioned(artist.name, video.title)

  if associate:
    logger.debug('Video matches artist: %s, associating' % (artist.name))

    artist.add_video(video)

    artist.save()

  return associate