<commit_before># hdbits.org

import string, os, urllib, zipfile, re, copy
from babelfish import Language
from datetime import timedelta
import subliminal
import logger

OS_PLEX_USERAGENT = 'plexapp.com v9.0'

DEPENDENCY_MODULE_NAMES = ['subliminal', 'enzyme', 'guessit', 'requests']

SUPPORTED_PROVIDERS = ['opensubtitles', 'thesubdb', 'podnapisi', 'addic7ed', 'tvsubtitles']

ENABLED_PROVIDERS = {'opensubtitles' : Prefs['provider.opensubtitles'],
                     'thesubdb' : Prefs['provider.thesubdb'],
                     'podnapisi' : Prefs['provider.podnapisi'],
                     'addic7ed' : Prefs['provider.addic7ed'],
                     'tvsubtitles' : Prefs['provider.tvsubtitles']
                     }
# dict((key,value) for key, value in a.iteritems() if key == 1)
SUPPORTED_PROVIDER_SETTINGS = {'addic7ed': { 
                                            'username': Prefs['provider.addic7ed.username'], 
                                            'password': Prefs['<PASSWORD>']
                                            }
                               }

def Start():
    HTTP.CacheTime = 0
    HTTP.Headers['User-agent'] = OS_PLEX_USERAGENT
    Log.Debug("START CALLED")
    logger.registerLoggingHander(DEPENDENCY_MODULE_NAMES)

def ValidatePrefs():
    Log.Debug("Validate Prefs called.")
    return 

# Prepare a list of languages we want subs for
def getLangList():
    langList = {Language.fromietf(Prefs["langPref1"])}
    if(Prefs["langPref2"] != "None"):
        langList.update({Language.fromietf(Prefs["langPref2"])})
        
    return langList

def getProviders():
    enabledProviders = []
    for supportedProvider in SUPPORTED_PROVIDERS:
        if Prefs["provider." + supportedProvider]:
            Log.Debug("Provider %s is enabled" % supportedProvider)
            enabledProviders.append(supportedProvider)
    return enabledProviders

def getProviderSettings():
    return SUPPORTED_PROVIDER_SETTINGS

class SubliminalSubtitlesAgentMovies(Agent.Movies):
    name = 'Subliminal Movie Subtitles'
    languages = [Locale.Language.English]
    primary_provider = False
    contributes_to = ['com.plexapp.agents.imdb']

    def search(self, results, media, lang):
        Log.Debug("MOVIE SEARCH CALLED")
        results.Append(MetadataSearchResult(id='null', score=100))


    def update(self, metadata, media, lang):
        Log.Debug("MOVIE UPDATE CALLED")
        for item in media.items:
            for part in item.parts:<commit_msg>Fixed movie subtitles uninitialized variable error<commit_after># hdbits.org

import string, os, urllib, zipfile, re, copy
from babelfish import Language
from datetime import timedelta
import subliminal
import logger

OS_PLEX_USERAGENT = 'plexapp.com v9.0'

DEPENDENCY_MODULE_NAMES = ['subliminal', 'enzyme', 'guessit', 'requests']

SUPPORTED_PROVIDERS = ['opensubtitles', 'thesubdb', 'podnapisi', 'addic7ed', 'tvsubtitles']

ENABLED_PROVIDERS = {'opensubtitles' : Prefs['provider.opensubtitles'],
                     'thesubdb' : Prefs['provider.thesubdb'],
                     'podnapisi' : Prefs['provider.podnapisi'],
                     'addic7ed' : Prefs['provider.addic7ed'],
                     'tvsubtitles' : Prefs['provider.tvsubtitles']
                     }
# dict((key,value) for key, value in a.iteritems() if key == 1)
SUPPORTED_PROVIDER_SETTINGS = {'addic7ed': { 
                                            'username': Prefs['provider.addic7ed.username'], 
                                            'password': Prefs['provider.addic7ed.password']
                                            }
                               }

def Start():
    HTTP.CacheTime = 0
    HTTP.Headers['User-agent'] = OS_PLEX_USERAGENT
    Log.Debug("START CALLED")
    logger.registerLoggingHander(DEPENDENCY_MODULE_NAMES)

def ValidatePrefs():
    Log.Debug("Validate Prefs called.")
    return 

# Prepare a list of languages we want subs for
def getLangList():
    langList = {Language.fromietf(Prefs["langPref1"])}
    if(Prefs["langPref2"] != "None"):
        langList.update({Language.fromietf(Prefs["langPref2"])})
        
    return langList

def getProviders():
    enabledProviders = []
    for supportedProvider in SUPPORTED_PROVIDERS:
        if Prefs["provider." + supportedProvider]:
            Log.Debug("Provider %s is enabled" % supportedProvider)
            enabledProviders.append(supportedProvider)
    return enabledProviders

def getProviderSettings():
    return SUPPORTED_PROVIDER_SETTINGS

class SubliminalSubtitlesAgentMovies(Agent.Movies):
    name = 'Subliminal Movie Subtitles'
    languages = [Locale.Language.English]
    primary_provider = False
    contributes_to = ['com.plexapp.agents.imdb']

    def search(self, results, media, lang):
        Log.Debug("MOVIE SEARCH CALLED")
        results.Append(MetadataSearchResult(id='null', score=100))


    def update(self, metadata, media, lang):
        videos = []
        Log.Debug("MOVIE UPDATE CALLED")
        for item in media.items:
            for part in item.parts:
{'fraction_non_alphanumeric': 0.11221056797941817, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 2.713445995591477, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5798527', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1491, 'n_words': 313}