コード例 #1
0
    def search(self, results, media, lang):
        if Prefs['strip_enable']:
            title = media.name.split(Prefs['strip_symbol'], 1)[0]
        else:
            title = media.name

        title = getSearchTitle(title)

        Log('***MEDIA TITLE [from media.name]*** %s' % title)
        searchSettings = PAsearchSites.getSearchSettings(title)
        Log(searchSettings)

        filepath = None
        filename = None
        if media.filename:
            filepath = urllib.unquote(media.filename)
            filename = str(os.path.splitext(os.path.basename(filepath))[0])

        if searchSettings['siteNum'] is None and filepath:
            directory = str(os.path.split(os.path.dirname(filepath))[1])

            newTitle = getSearchTitle(directory)
            Log('***MEDIA TITLE [from directory]*** %s' % newTitle)
            searchSettings = PAsearchSites.getSearchSettings(newTitle)

            if searchSettings['siteNum'] is not None and searchSettings[
                    'searchTitle'].lower() == PAsearchSites.getSearchSiteName(
                        searchSettings['siteNum']).lower():
                newTitle = '%s %s' % (newTitle, title)
                Log('***MEDIA TITLE [from directory + media.name]*** %s' %
                    newTitle)
                searchSettings = PAsearchSites.getSearchSettings(newTitle)

        siteNum = searchSettings['siteNum']

        if siteNum is not None:
            search = PAsearchData.SearchData(media,
                                             searchSettings['searchTitle'],
                                             searchSettings['searchDate'],
                                             filepath, filename)

            provider = PAsiteList.getProviderFromSiteNum(siteNum)
            if provider is not None:
                providerName = getattr(provider, '__name__')
                Log('Provider: %s' % providerName)
                provider.search(results, lang, siteNum, search)

        results.Sort('score', descending=True)
コード例 #2
0
    def search(self, results, media, lang):
        title = PAutils.getSearchTitleStrip(media.name)
        title = PAutils.getCleanSearchTitle(title)

        Log('***MEDIA TITLE [from media.name]*** %s' % title)
        searchSettings = PAsearchSites.getSearchSettings(title)
        Log(searchSettings)

        filepath = None
        filename = None
        if media.filename:
            filepath = urllib.unquote(media.filename)
            filename = str(os.path.splitext(os.path.basename(filepath))[0])
            filename = PAutils.getSearchTitleStrip(filename)

        if searchSettings['siteNum'] is None and filepath:
            directory = str(os.path.split(os.path.dirname(filepath))[1])
            directory = PAutils.getSearchTitleStrip(directory)

            newTitle = PAutils.getCleanSearchTitle(directory)
            Log('***MEDIA TITLE [from directory]*** %s' % newTitle)
            searchSettings = PAsearchSites.getSearchSettings(newTitle)

            if searchSettings['siteNum'] is None:
                if title == newTitle and title != filename:
                    title = filename

                newTitle = '%s %s' % (newTitle, title)
                Log('***MEDIA TITLE [from directory + media.name]*** %s' % newTitle)
                searchSettings = PAsearchSites.getSearchSettings(newTitle)

        providerName = None
        siteNum = searchSettings['siteNum']
        searchTitle = searchSettings['searchTitle']
        if not searchTitle:
            searchTitle = title
        searchDate = searchSettings['searchDate']
        search = PAsearchData.SearchData(media, searchTitle, searchDate, filepath)

        if siteNum is not None:
            provider = PAsiteList.getProviderFromSiteNum(siteNum)
            if provider is not None:
                providerName = getattr(provider, '__name__')
                Log('Provider: %s' % providerName)
                try:
                    provider.search(results, lang, siteNum, search)
                except Exception as e:
                    Log.Error(format_exc())

        if Prefs['metadataapi_enable'] and providerName != 'networkMetadataAPI' and (siteNum is None or not results or 100 != max([result.score for result in results])):
            siteNum = PAsearchSites.getSiteNumByFilter('MetadataAPI')
            if siteNum is not None:
                provider = PAsiteList.getProviderFromSiteNum(siteNum)
                if provider is not None:
                    providerName = getattr(provider, '__name__')
                    Log('Provider: %s' % providerName)
                    try:
                        provider.search(results, lang, siteNum, search)
                    except Exception as e:
                        Log.Error(format_exc())

        results.Sort('score', descending=True)
コード例 #3
0
    def search(self, results, media, lang):
        if Prefs['strip_enable']:
            title = media.name.split(Prefs['strip_symbol'], 1)[0]
        else:
            title = media.name

        title = getSearchTitle(title)

        Log('***MEDIA TITLE [from media.name]*** %s' % title)
        searchSettings = PAsearchSites.getSearchSettings(title)
        Log(searchSettings)

        filepath = None
        filename = None
        if media.filename:
            filepath = urllib.unquote(media.filename)
            filename = str(os.path.splitext(os.path.basename(filepath))[0])

        if searchSettings['siteNum'] is None and filepath:
            directory = str(os.path.split(os.path.dirname(filepath))[1])

            newTitle = getSearchTitle(directory)
            Log('***MEDIA TITLE [from directory]*** %s' % newTitle)
            searchSettings = PAsearchSites.getSearchSettings(newTitle)

            if searchSettings['siteNum'] is None:
                if title == newTitle and title != filename:
                    title = filename

                newTitle = '%s %s' % (newTitle, title)
                Log('***MEDIA TITLE [from directory + media.name]*** %s' %
                    newTitle)
                searchSettings = PAsearchSites.getSearchSettings(newTitle)

        #Use AdultEmpire to check dvd split scenes automatically
        if searchSettings['siteNum'] is None:
            Log("checking for adultempire")
            scene_title = re.search(r'.*(?=.Scene\s\d)', title)
            if scene_title is not None:
                searchSettings = {
                    'siteNum': 1334,
                    'siteName': "Adult Empire",
                    'searchTitle': title,
                    'searchDate': None,
                }

        providerName = None
        siteNum = searchSettings['siteNum']
        searchTitle = searchSettings['searchTitle']
        if not searchTitle:
            searchTitle = title
        searchDate = searchSettings['searchDate']
        search = PAsearchData.SearchData(media, searchTitle, searchDate,
                                         filepath)

        if siteNum is not None:
            provider = PAsiteList.getProviderFromSiteNum(siteNum)
            if provider is not None:
                providerName = getattr(provider, '__name__')
                Log('Provider: %s' % providerName)
                try:
                    provider.search(results, lang, siteNum, search)
                except Exception as e:
                    Log.Error(format_exc())

        if Prefs[
                'metadataapi_enable'] and providerName != 'networkMetadataAPI' and (
                    siteNum is None or not results
                    or 100 != max([result.score for result in results])):
            siteNum = PAsearchSites.getSiteNumByFilter('MetadataAPI')
            if siteNum is not None:
                provider = PAsiteList.getProviderFromSiteNum(siteNum)
                if provider is not None:
                    providerName = getattr(provider, '__name__')
                    Log('Provider: %s' % providerName)
                    try:
                        provider.search(results, lang, siteNum, search)
                    except Exception as e:
                        Log.Error(format_exc())

        results.Sort('score', descending=True)