<commit_before>// @flow
import { getVersionInfo } from '../versionInfo';

import { type IProvider } from './types';

const MARKETVERSION_STARTTOKEN = 'softwareVersion">';
const MARKETVERSION_ENDTOKEN = '<';
const MARKETVERSION_STARTTOKEN_NEW =
  'Current Version</div><div><span class="htlgb">';

export type PlayStoreGetVersionOption = {
  packageName?: string,
  fetchOptions?: any,
  ignoreErrors?: boolean,
};

export interface IPlayStoreProvider extends IProvider {
  getVersion: PlayStoreGetVersionOption => Promise<string>;
}

function error(text: string) {
  return {
    message:
      "Parse Error. Your app's play store page doesn't seem to have div[itemprop=softwareVersion].",
    text,
  };
}

class PlayStoreProvider implements IProvider {
  getVersion(option: PlayStoreGetVersionOption): Promise<string> {
    try {
      if (!option.packageName) {
        option.packageName = getVersionInfo().getPackageName();
      }

      return fetch(
        `https://play.google.com/store/apps/details?id=${option.packageName}`,
        option.fetchOptions<commit_msg>fix: playStore's market version tokens<commit_after>// @flow
import { getVersionInfo } from '../versionInfo';

import { type IProvider } from './types';

const MARKETVERSION_STARTTOKEN = 'softwareVersion">';
const MARKETVERSION_ENDTOKEN = '</span>';
const MARKETVERSION_STARTTOKEN_NEW = 'Current Version</div><span class="htlgb"><div><span class="htlgb">';

export type PlayStoreGetVersionOption = {
  packageName?: string,
  fetchOptions?: any,
  ignoreErrors?: boolean,
};

export interface IPlayStoreProvider extends IProvider {
  getVersion: PlayStoreGetVersionOption => Promise<string>;
}

function error(text: string) {
  return {
    message:
      "Parse Error. Your app's play store page doesn't seem to have div[itemprop=softwareVersion].",
    text,
  };
}

class PlayStoreProvider implements IProvider {
  getVersion(option: PlayStoreGetVersionOption): Promise<string> {
    try {
      if (!option.packageName) {
        option.packageName = getVersionInfo().getPackageName();
      }

      return fetch(
        `https://play.google.com/store/apps/details?id=${option.packageName}`,
        option.fetchOptions
{'fraction_non_alphanumeric': 0.12130849613811903, 'fraction_numerical': 0.0, 'mean_word_length': 4.437037037037037, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 19, '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': '4263115', 'n_tokens_mistral': 635, 'n_tokens_neox': 627, 'n_words': 149}