<commit_before>#!/usr/bin/python
import lyricsapi
import urllib2

__siteID__ = 'MetaHub'
__version__ = 1
__author__ = '<NAME>'

class Fetch(lyricsapi.Fetcher):
       
    def makeURL(self):
        artist = urllib2.quote(self.artist)
        title = urllib2.quote(self.title)
        url = 'https://tunehubmeta.appspot.com/get?artist=' + artist + '&title=' + title
        self.url = url
        return url

    def getLyric(self):
        url = self.makeURL()
        try:
            page = urllib2.urlopen(url)
            lyrics = page.read()
        except:
            lyrics = 'Error'
        
        self.lyrics = lyrics
        return lyrics
    
    def get(self):
        self.getLyric()
        lyrics = unicode(self.lyrics)
        return lyrics
    
if __name__ == '__main__':
    artist = raw_input('Artist: ')
    title = raw_input('Title: ')
    api = Fetch(artist, title)
    print api.get()<commit_msg>Ensures that metahub returns NoneType if no lyrics were found<commit_after>#!/usr/bin/python
import lyricsapi
import urllib2

__siteID__ = 'MetaHub'
__version__ = 1
__author__ = '<NAME>'

class Fetch(lyricsapi.Fetcher):
       
    def makeURL(self):
        artist = urllib2.quote(self.artist)
        title = urllib2.quote(self.title)
        url = 'https://tunehubmeta.appspot.com/get?artist=' + artist + '&title=' + title
        self.url = url
        return url

    def getLyric(self):
        url = self.makeURL()
        try:
            page = urllib2.urlopen(url)
            lyrics = page.read()
            if len(lyrics) < 6:
                lyrics = None
        except:
            lyrics = None
        
        self.lyrics = lyrics
        return lyrics
    
    def get(self):
        self.getLyric()
        if self.lyrics == None:
            return None
        else:
            lyrics = unicode(self.lyrics)
            return lyrics
    
if __name__ == '__main__':
    artist = raw_input('Artist: ')
    title = raw_input('Title: ')
    api = Fetch(artist, title)
    print api.get()
    print type(api.lyrics)
{'fraction_non_alphanumeric': 0.11224489795918367, 'fraction_numerical': 0.005344995140913508, 'mean_word_length': 1.933048433048433, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6106138', 'n_tokens_mistral': 675, 'n_tokens_neox': 673, 'n_words': 147}