<commit_before>'use strict';

const { MovieInfo, SearchResult } = require('../../models/types.js');
const leech = require('../leech-promise.js');
const util = require('../util.js');
const dict = require('../category-dictionary.js');

const urlParse = require('url').parse;
const querystring = require('querystring');

const NAME = 'avent';
module.exports.name = function () {
    return NAME;
}

const TEMPLATE = {
    "search": "http://www.aventertainments.com/search_Products.aspx?languageID={lang}&keyword={qtext}&searchby=keyword",
    "id": "http://www.aventertainments.com/product_lists.aspx?product_id={qtext}&languageID={lang}&dept_id=29",
}

const LANG_TMP = {
    "en": "1",
    "ja": "2",
}

const DOMAIN = 'www.aventertainments.com';
module.exports.domain = function () {
    return DOMAIN;
}

const BASE_URL = 'http://' + DOMAIN;

const LangMap = {
    'releasedate': { 'ja': '発売日:', 'en': 'Release Date:' },
    'duration': { 'ja': '収録時間:', 'en': 'Play time:' },
    'maker': { 'ja': 'スタジオ:', 'en': 'Studio:' },
    'title': { 'ja': '商品番号:', 'en': 'Item#:' },
    'actors': { 'ja': '主演女優:', 'en': 'Starring:' },
    'genres': { 'ja': 'カテゴリ一覧:', 'en': 'Category:' },
}

function getFootprint (data) {
    return {
        "crawler": NAME,
        "id": data.movid,
    };
}

function formatMovId (val) {
    var uri = urlParse(val);
    var qstr = querystring.parse(
        uri.path.replace(uri.pathname, '')
    );
    return qstr['product_id'];
}

function formatReleaseDate (val) {
    val = val.replace('Release Date', 'ReleaseDate').split(' ')[1];
    val = val.split('/');

    var day = parseInt(val[1]), 
        month = parseInt(val[0]), 
        year = parseInt(val[2]);

    if (day < 10) day = '0' + day;
    if (month < 10) month = '0' + month;

    return year + '-' + month + '-' + day;
}

function formatDuration (val) {
    val = val.replace('Play time', 'Playtime').split(' ')[2];
    let minutes = parseInt(val);
    let hours = Math.floor(minutes / 60);
    minutes = minutes - hours * 60;

    if (hours < 10) { hours = '0' + hours; }
    if (minutes < 10) { minutes = '0' + minutes; }

    return hours + ':' + minutes + ':' + '00';
}

function formatSearchText (val) {
    var uri = urlParse(val);
    var qstr = querystring.parse(
        uri.path.replace(uri.pathname, '')
    );
    return qstr['keyword'];
}

function thenIfSearch ($, lang) {
    let result = new SearchResult({url: $.getCurrentURL(), footprint: getFootprint});
    result.queryString = formatSearchText(result.url);

    $('table[id$="MyList"] table').each((i, el) => {
        let ele = $(el);
        let info = new MovieInfo();

        ele = ele.find('td').eq(1)[0];
        info.url = ele.childNodes[1].attribs["href"];
        if (lang == 'en') {
            info.transtitle = util.wrapText(ele.childNodes[1].children[0].data.trim());
        }
        if (lang == 'ja') {
            info.origtitle = util.wrapText(ele.childNodes[1].children[0].data.trim());
        }
        info.title = ele.childNodes[13].data.replace(LangMap['title'][lang], '').trim();
        info.posters.push({
            url: `http://imgs.aventertainments.com/new/jacket_images/dvd1${info.title.toLowerCase()}.jpg`
        });

        result.results.push(info);
    })

    result.more = $('.pagination').eq(0).find('a').length > 3;

    if (result.results.length == 1) {<commit_msg>Add movid into SearchResult<commit_after>'use strict';

const { MovieInfo, SearchResult } = require('../../models/types.js');
const leech = require('../leech-promise.js');
const util = require('../util.js');
const dict = require('../category-dictionary.js');

const urlParse = require('url').parse;
const querystring = require('querystring');

const NAME = 'avent';
module.exports.name = function () {
    return NAME;
}

const TEMPLATE = {
    "search": "http://www.aventertainments.com/search_Products.aspx?languageID={lang}&keyword={qtext}&searchby=keyword",
    "id": "http://www.aventertainments.com/product_lists.aspx?product_id={qtext}&languageID={lang}&dept_id=29",
}

const LANG_TMP = {
    "en": "1",
    "ja": "2",
}

const DOMAIN = 'www.aventertainments.com';
module.exports.domain = function () {
    return DOMAIN;
}

const BASE_URL = 'http://' + DOMAIN;

const LangMap = {
    'releasedate': { 'ja': '発売日:', 'en': 'Release Date:' },
    'duration': { 'ja': '収録時間:', 'en': 'Play time:' },
    'maker': { 'ja': 'スタジオ:', 'en': 'Studio:' },
    'title': { 'ja': '商品番号:', 'en': 'Item#:' },
    'actors': { 'ja': '主演女優:', 'en': 'Starring:' },
    'genres': { 'ja': 'カテゴリ一覧:', 'en': 'Category:' },
}

function getFootprint (data) {
    return {
        "crawler": NAME,
        "id": data.movid,
    };
}

function formatMovId (val) {
    var uri = urlParse(val);
    var qstr = querystring.parse(
        uri.path.replace(uri.pathname, '')
    );
    return qstr['product_id'];
}

function formatReleaseDate (val) {
    val = val.replace('Release Date', 'ReleaseDate').split(' ')[1];
    val = val.split('/');

    var day = parseInt(val[1]), 
        month = parseInt(val[0]), 
        year = parseInt(val[2]);

    if (day < 10) day = '0' + day;
    if (month < 10) month = '0' + month;

    return year + '-' + month + '-' + day;
}

function formatDuration (val) {
    val = val.replace('Play time', 'Playtime').split(' ')[2];
    let minutes = parseInt(val);
    let hours = Math.floor(minutes / 60);
    minutes = minutes - hours * 60;

    if (hours < 10) { hours = '0' + hours; }
    if (minutes < 10) { minutes = '0' + minutes; }

    return hours + ':' + minutes + ':' + '00';
}

function formatSearchText (val) {
    var uri = urlParse(val);
    var qstr = querystring.parse(
        uri.path.replace(uri.pathname, '')
    );
    return qstr['keyword'];
}

function thenIfSearch ($, lang) {
    let result = new SearchResult({url: $.getCurrentURL(), footprint: getFootprint});
    result.queryString = formatSearchText(result.url);

    $('table[id$="MyList"] table').each((i, el) => {
        let ele = $(el);
        let info = new MovieInfo();

        ele = ele.find('td').eq(1)[0];
        info.url = ele.childNodes[1].attribs["href"];
        info.movid = formatMovId(info.url);
        if (lang == 'en') {
            info.transtitle = util.wrapText(ele.childNodes[1].children[0].data.trim());
        }
        if (lang == 'ja') {
            info.origtitle = util.wrapText(ele.childNodes[1].children[0].data.trim());
        }
        info.title = ele.childNodes[13].data.replace(LangMap['title'][lang], '').trim();
        info.posters.push({
            url: `http://imgs.aventertainments.com/new/jacket_images/dvd1${info.title.toLowerCase()}.jpg`
        });

        result.results.push(info);
    })

    result.more = $('.pagination').eq(0).find('a').length > 3;

    if (result.results.length == 1) {
{'fraction_non_alphanumeric': 0.20581327069876687, 'fraction_numerical': 0.011743981209630064, 'mean_word_length': 3.0194690265486726, 'pattern_counts': {'":': 12, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '623402', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2380, 'n_words': 473}