Plugin for non-IMDB site

plz help
I'm trying to create metadata agent for Russian IMDB — kinopoisk.ru, cause default plugin does not recognize almost all filenames (and we need meta in Russian =)

I took default imdb.bundle and stuck =(

First of all, there is no year in search result (titleNoFormatting), for example for Avatar ([link](http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&q=avatar+site:kinopoisk.ru)) titleNoFormatting is "Аватар" and this is desired name in Russian (kinopoisk.ru google index and internal site search are really good, it can find movie by both eng and rus names). So I removed imdbYear from here (or it drops to "strange title"):


           # Parse the name and year.<br />
            kinopoiskName = self.parseTitle(title)<br />
            if not kinopoiskName:<br />
              # Doesn't match, let's skip it.<br />
              Log("Skipping strange title: " + title)<br />
              continue<br />
            else:<br />
              Log("Using [%s] from [%s]" % (kinopoiskName, title))<br />




Than search:



            if len(splitUrl) == 7 and splitUrl[-2].startswith('fil'):<br />
              id = splitUrl[-1]<br />
              Log("Found id " + id)              <br />
              if id.count('+') > 0:<br />
                # Penalizing for abnormal tt link.<br />
                Log("SAME ID" + id)              <br />
                scorePenalty += 10<br />
              try:<br />
                # Don't process for the same ID more than once.<br />
                if idMap.has_key(id):<br />
                  continue<br />
                  <br />
                idMap[id] = True<br />
                <br />
                # Check to see if the item's release year is in the future, if so penalize.<br />
                if kinopoiskYear > datetime.datetime.now().year:<br />
                  Log(kinopoiskName + ' penalizing for future release date')<br />
                  scorePenalty += 25<br />
                  Log("FUTURE")              <br />
              <br />
                # Sanity check to make sure we have SOME common substring.<br />
                longestCommonSubstring = len(Util.LongestCommonSubstring(media.name.lower(), kinopoiskName.lower()))<br />
                Log("LCS!" + Util.LongestCommonSubstring(media.name.lower(), kinopoiskName.lower()))<br />
                <br />
                # If we don't have at least 10% in common, then penalize below the 80 point threshold<br />
                if (float(longestCommonSubstring) / len(media.name)) < .15: <br />
                  scorePenalty += 25<br />
                  Log("LENGTH")<br />
                <br />
                # Finally, add the result.<br />
                results.Append(MetadataSearchResult(id = id, name  = kinopoiskName, year = year, lang  = lang, score = score - (scorePenalty + subsequentSearchPenalty)))<br />
              except:<br />
                Log('Kinopoisk Result ' + id)<br />
                pass<br />
           <br />
            # Each search entry is worth less, but we subtract even if we don't use the entry...might need some thought.<br />
            score = score - 4 




logfile talks about some results looks like:


2010-09-16 20:48:15,945 (-4faed000) :  INFO (__init__) - Using [(None, None)] from [Аватар]<br />
2010-09-16 20:48:15,945 (-4faed000) :  INFO (__init__) - Found id 251733<br />
2010-09-16 20:48:15,945 (-4faed000) :  INFO (__init__) - Kinopoisk Result 251733



But when I try "Fix incorrect match", searchlist is empty =( What's wrong?

Well, it seems you got an exception because the log shows: “Kinopoisk Result 251733”. You show that only in the “except:” clause. I recommend that you delete the try except sentence. If you do that you’ll see the exception in the log and you’ll find the reason of the error. You don’t see any result because the exception occurs before de Append and the control jumps into the except clause.



thank you

any idea why it occurs? =( results are right

Remove the try and the except lines (be carreful with indents) and then post the log. I’m sure that I’ll be able to help you with more information.



removed, leave only


           results.Append(MetadataSearchResult(id = id, name  = kinopoiskName, lang  = lang, score = score - (scorePenalty + subsequentSearchPenalty)))


(leaving 'year' cause fatal error)

results now shown up is search windows, but unusable:

[http://img.skitch.com/20100916-tnmy3d5nkwudqwyyd4bqadn8pi.preview.jpg](http://skitch.com/ptath/danut/mini)

here is log:


2010-09-17 01:32:46,766 (-4f9e9000) :  INFO (__init__) - Using [(None, None)] from [Аватар]<br />
2010-09-17 01:32:46,766 (-4f9e9000) :  INFO (__init__) - Found id 251733<br />




and code, causing this:


            # Parse the name and year.<br />
            kinopoiskName = self.parseTitle(title)<br />
            if not kinopoiskName:<br />
              # Doesn't match, let's skip it.<br />
              Log("Skipping strange title: " + title)<br />
              continue<br />
            else:<br />
              Log("Using [%s] from [%s]" % (kinopoiskName, title))<br />




original IMDB code:


            # Parse the name and year.<br />
            imdbName, imdbYear = self.parseTitle(title)<br />
            if not imdbName:<br />
              # Doesn't match, let's skip it.<br />
              Log("Skipping strange title: " + title)<br />
              continue<br />
            else:<br />
              Log("Using [%s] derived from [%s]" % (imdbName, title))

parseTitle returns a tuple, not a string. If you are using the same parseTitle of IMDB, you should write:


<br />
kinopoiskName,kinopoiskYear = self.parseTitle(title)<br />



Now kinopoiskName will be a string and you can deal with that variable like a string (using lower(),...).

(None,None) means that parseTitle has failed. You must see what happens there.



2010-09-17 19:01:15,074 (-4faed000) :  DEBUG (networking) - Requesting http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&q=Avatar+kinopoisk.ru<br />
2010-09-17 19:01:15,800 (-4faed000) :  INFO (__init__) - Skipping strange title: Аватар<br />




But this is good title


           # Parse the name and year.<br />
            kinopoiskName, kinopoiskYear = self.parseTitle(title)<br />
            if not kinopoiskName:<br />
              # Doesn't match, let's skip it.<br />
              Log("Skipping strange title: " + title)<br />
              continue<br />
            else:<br />
              Log("Using [%s] from [%s]" % (kinopoiskName, title))<br />




I do not understand what "kinopoiskName, kinopoiskYear = self.parseTitle(title)" actually do and how works "if not kinopoiskName:". Without Year it passes.

I think you need to learn python a bit more. You don’t know the basics of this language. I recommend you read the tutorial here.



kinopoiskName has the value (None,None) because parseTitle returns a tuple (name,year), but this function can’t recognize the title that you passed as an argument and returns None in year and None in name.

The control sentence “if” gives cotrol to the next indented body if the expresion evaluates to True (or to not None). If you have in mind that (None,None) != None and that None == False then (None,None) == True:


<br />
not kinopoiskName -> not (None,None) -> not True -> False<br />




The expresion value is False then the control flows to the "else" sentence:

<br />
else:<br />
     Log("Using [%s] from [%s]" % (kinopoiskName, title))<br />




Absolutely right, but this is an only script I wish to write with python =)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.