<commit_before><link rel="import" href="../connector.html">

<script>

    /**
     *
     */
    class Gntai extends Connector {

        /**
         *
         */
        constructor() {
            super();
            super.id         = 'gntai';
            super.label      = 'GNTAI';
            this.tags        = [ 'hentai', 'spanish' ];
            this.url         = 'http://www.gntai.xyz';
        }

        /**
         * Similar to DoujinDesu => Blogger
         */
        _getMangaFromURI( uri ) {
            let request = new Request( uri.href, this.requestOptions );
            return this.fetchDOM( request, 'meta[property="og:title"]' )
            .then( data => {
                let id = uri.pathname + uri.search;
                let title = data[0].content.trim();
                return Promise.resolve( new Manga( this, id, title ) );
            } );
        }

        /**
         * Similar to DoujinDesu => Blogger
         */
        _getMangaListFromPages( mangaPageLinks, index ) {
            index = index || 0;
            let request = new Request( mangaPageLinks[ index ], this.requestOptions );
            return this.fetchJSON( request )
            .then( data => {
                let mangaList = data.feed.entry.map( entry => {
                    return {
                        id: this.getRootRelativeOrAbsoluteLink( entry.link.find( a => a.rel === 'alternate' ).href, request.url ),
                        title: entry.title.$t.trim()
                    };
                } );
                if( index < mangaPageLinks.length - 1 ) {
                    return this._getMangaListFromPages( mangaPageLinks, index + 1 )
                    .then( mangas => mangaList.concat( mangas ) );
                } else {
                    return Promise.resolve( mangaList );
                }
            } );
        }

        /**
         * Similar to DoujinDesu => Blogger
         */
        _getMangaPageLinks( path ) {
            let script = `
            new Promise( resolve => {
                let result = document.querySelector( 'div#nav-wrapper select#select-nav-pag option:last-of-type' );
                resolve( result.textContent.trim() );
            } );
            `;
            let request = new Request( this.url + '/' + path, this.requestOptions );
            return Engine.Request.fetchUI( request, script )
            .then( data => {
                let pageCount = parseInt( data );
                let pageLinks = [...( new Array( pageCount ) ).keys()].map( page => this.url + `/feeds/posts/default/-/_${path}?alt=json&max-results=50&start-index=` + ( 50 * page + 1 ) );
                return Promise.resolve( pageLinks );
            } );
        }

        /**
         *
         */
        _getMangaList( callback ) {
            let promises = [ 'mangas', 'doujinshis' ].map( path => this._getMangaPageLinks( path ) );
            Promise.all( promises )
            .then( data => {
                let pageLinks = [].concat.apply( [], data );
                return this._getMangaListFromPages( pageLinks );
            } )
            .then( data => {
                callback( null, data );
            } )
            .catch( error => {
                console.error( error, this );
                callback( error, undefined );
            } );
        }

        /**
         *
         */
        _getChapterList( manga, callback ) {
            Promise.resolve()
            .then( data => {
                let chapterList = [ {
                    id: manga.id,
                    title: manga.title,
                    language: ''
                } ];
                callback( null, chapterList );
            } )
            .catch( error => {
                console.error( error, manga );
                callback( error, undefined );
            } );
        }

        /**
         *
         */
        _getPageList( manga, chapter, callback ) {
            let request = new Request( this.url + chapter.id, this.requestOptions );
            Engine.Request.fetchUI( request, `pages` )
            .then( data => {             
                callback( null, data );
            } )
            .catch( error => {
                console.error( error, chapter );
                callback( error, undefined );
            } );
        }
    }

</script><commit_msg>[gntai] switched to blogger template<commit_after><link rel="import" href="blogger-manga.html">

<script>

    /**
     *
     */
    class Gntai extends BloggerManga {

        /**
         *
         */
        constructor() {
            super();
            super.id         = 'gntai';
            super.label      = 'GNTAI';
            this.tags        = [ 'hentai', 'spanish' ];
            this.url         = 'http://www.gntai.xyz';

            this.path        = '/page';
            this.feed        = 'default';
            this.queryMangasPerPage = 50;
            this.queryMangasPageCount = 'div#nav-wrapper select#select-nav-pag option:last-of-type';
        }

        /**
         *
         */
        _getChapterList( manga, callback ) {
            Promise.resolve()
            .then( data => {
                let chapterList = [ {
                    id: manga.id,
                    title: manga.title,
                    language: ''
                } ];
                callback( null, chapterList );
            } )
            .catch( error => {
                console.error( error, manga );
                callback( error, undefined );
            } );
        }

        /**
         *
         */
        _getPageList( manga, chapter, callback ) {
            let request = new Request( this.url + chapter.id, this.requestOptions );
            Engine.Request.fetchUI( request, `pages` )
            .then( data => {             
                callback( null, data );
            } )
            .catch( error => {
                console.error( error, chapter );
                callback( error, undefined );
            } );
        }
    }

</script>
{'fraction_non_alphanumeric': 0.12555610479485912, 'fraction_numerical': 0.001812489701763058, 'mean_word_length': 1.1246062303115156, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6810072', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1543, 'n_words': 326}