import _ from 'lodash';
import i18n from '../shared/i18n';
import { fetchJSON } from '../shared/fetcher';
import BaseDownloader from './base_downloader';

class ContentRunner {

    fetch(item) {
        // This part should be changed to embed unfluff code.
        const url = `https://qianliyan.herokuapp.com/extract?url=${item.link}&lang=${item.lang}`;
        return fetchJSON(url);
    }

    process(json, task) {
        task.resolve({ text: json.text, lang: json.lang || task.url.lang });
    }
}

const singleton = new BaseDownloader(new ContentRunner());

export default singleton;

@@ -17,16 +17,62 @@
 odash';%0A
+import extractText from '../unfluff/unfluff';%0A
 import i
@@ -112,20 +112,20 @@
  %7B fetch
-JSON
+Text
  %7D from 
@@ -227,20 +227,19 @@
   fetch(
-item
+url
 ) %7B%0A    
@@ -246,158 +246,98 @@
     
-// This part should be changed to embed unfluff code.%0A        const url = %60https://qianliyan.herokuapp.com/extract?url=$%7Bitem.link%7D&lang=$%7Bitem
+return fetchText(url.link).then((html) =%3E %7B%0A            return extractText(html, url
 .lang
-%7D%60
+)
 ;%0A  
@@ -346,28 +346,9 @@
     
-return fetchJSON(url
+%7D
 );%0A 

use embeded unfluff instead use a remote server (untested)