获取进程名称
        :param subtitle:
        :return:
420995
def make_proc_name(self, subtitle):
        
        proc_name = '[%s:%s %s] %s' % (
            constants.NAME,
            subtitle,
            self.name,
            ' '.join([sys.executable] + sys.argv)
        )

        return proc_name
1118880
public Subtitle getSubtitle(int trackID) throws MusixMatchException {
        Subtitle subtitle = null;
        SubtitleGetMessage message = null;
        Map<String, Object> params = new HashMap<String, Object>();

        params.put(Constants.API_KEY, apiKey);
        params.put(Constants.TRACK_ID, new String("" + trackID));

        String response = null;

        response = MusixMatchRequest.sendRequest(Helper.getURLString(
				Methods.TRACK_SUBTITLE_GET, params));

        Gson gson = new Gson();

        try {
            message = gson.fromJson(response, SubtitleGetMessage.class);
        } catch (JsonParseException jpe) {
            jpe.printStackTrace();
            handleErrorResponse(response);
        }

        subtitle = message.getContainer().getBody().getSubtitle();

        return subtitle;
    }
1023000
def underscore(name):
    '''
    
    '''

    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
700709
def format(self, subtitles):
        
        logger.debug('Formatting subtitles (id=%s) with %s',
            subtitles.id, self.__class__.__name__)
        return self._format(subtitles).encode('utf-8')
653414
def json_formatter(subtitles):
    
    subtitle_dicts = [
        {
            'start': start,
            'end': end,
            'content': text,
        }
        for ((start, end), text)
        in subtitles
    ]
    return json.dumps(subtitle_dicts)
660148
def _subtitlesRemoved(self, path, subNos):
        """"""
        def action(current, count, model, row):
            if count.equal > 0:
                model.removeRow(row)
            else:
                _setSubNo(current - count.greater_equal, model, row)

        def count(current, nos):
            return _GtEqCount(current, nos)

        self._changeSubNos(path, subNos, count, action)
24383
def title_translations(self, key, value):
    """"""
    return {
        'language': langdetect.detect(value.get('a')),
        'source': value.get('9'),
        'subtitle': value.get('b'),
        'title': value.get('a'),
    }
1186673
def _build_hash_magic(self, subtitle_id):
        

        media_magic = self.HASH_MAGIC_CONST ^ subtitle_id
        hash_magic = media_magic ^ media_magic >> 3 ^ media_magic * 32
        return str(hash_magic)
921436
def slug_sub(match):
    
    level = match.group(1)
    title = match.group(2)
    slug = title.lower()
    slug = re.sub(r'<.+?>|[^\w-]', ' ', slug)
    slug = re.sub(r'[ \t]+', ' ', slug).strip()
    slug = slug.replace(' ', '-')
    if slug:
        return '<{0} id="{1}">{2}</{0}>'.format(level, slug, title)
    return match.group(0)
1045565
public function suggest($title, $subtitles)
    {
        if (count($subtitles) == 1) {
            return 1;
        }

        $hdTags = array('HD', '720p', '1080p');

        $hd = false;

        foreach ($hdTags as $hdTag) {
            if (stripos($title, $hdTag)) {
                $hd = true;
            }
        }

        $weights = array();

        foreach ($subtitles as $subtitle) {
            $weight = $subtitle->hd === true ? 1 : 0;

            $matches = $this->versionMatch($title, $subtitle->version);

            if ($matches) {
                $weight += $matches * 2;
            }

            $weights[$subtitle->id] = $weight;
        }

        arsort($weights);

        return key($weights);
    }
446939
function checkSubtitleFiles(options, fileWithHashes) {
    if (options.verbose) {
        _utils.logger.info('Checking existing subtitles...');
    }
    var promises = [];
    var _iteratorNormalCompletion3 = true;
    var _didIteratorError3 = false;
    var _iteratorError3 = undefined;

    try {
        for (var _iterator3 = fileWithHashes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
            var file = _step3.value;

            promises.push(_utils.fileManager.subtitleExists(options, file));
        }
    } catch (err) {
        _didIteratorError3 = true;
        _iteratorError3 = err;
    } finally {
        try {
            if (!_iteratorNormalCompletion3 && _iterator3.return) {
                _iterator3.return();
            }
        } finally {
            if (_didIteratorError3) {
                throw _iteratorError3;
            }
        }
    }

    return Promise.all(promises);
}
506066
def getPythonVarName(name):
    
    return SUB_REGEX.sub('', name.replace('+', '_').replace('-', '_').replace('.', '_').replace(' ', '').replace('/', '_')).upper()
792634
def libvlc_video_set_subtitle_file(p_mi, psz_subtitle):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \
        _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None,
                    ctypes.c_int, MediaPlayer, ctypes.c_char_p)
    return f(p_mi, psz_subtitle)
1266217
async function getSubtitles (file) {
  for (const provider of SUBTITLES_PROVIDERS) {
    try {
      return await provider.getSubtitles(file)
    } catch (err) {
      console.error(`Subtitles not found on ${provider.name}`)
    }
  }
}
1195252
def parse_subprotocol_item(
    header: str, pos: int, header_name: str
) -> Tuple[Subprotocol, int]:
    
    item, pos = parse_token(header, pos, header_name)
    return cast(Subprotocol, item), pos
414212
def srt_formatter(subtitles, padding_before=0, padding_after=0):
    
    sub_rip_file = pysrt.SubRipFile()
    for i, ((start, end), text) in enumerate(subtitles, start=1):
        item = pysrt.SubRipItem()
        item.index = i
        item.text = six.text_type(text)
        item.start.seconds = max(0, start - padding_before)
        item.end.seconds = end + padding_after
        sub_rip_file.append(item)
    return '\n'.join(six.text_type(item) for item in sub_rip_file)
1067996
def set_itunes_subtitle(self):
        """"""
        try:
            self.itunes_subtitle = self.soup.find('itunes:subtitle').string
        except AttributeError:
            self.itunes_subtitle = None