Beispiel #1
0
func (e *Extractor) Process(job J.Job) {
	job.Progress("Extracting...")

	defer e.wg.Done()
	resp, err := e.extractRetry(job.Url, job.Content)
	if err != nil {
		e.error(job, "%s", err)
		return
	}

	doc, err := rewriteAndDownloadImages(job.Root(), resp.Content)
	if err != nil {
		e.error(job, "HTML parsing failed: %s", err)
		return
	}

	job.Doc = doc
	if resp.Title != "" {
		job.Title = resp.Title
	}
	job.Domain = resp.Domain
	if resp.Author != nil {
		job.Author = *resp.Author
	}

	job.Progress("Extraction complete...")
	e.Output <- job
}
Beispiel #2
0
func (c *Cleaner) Process(job J.Job) {
	defer c.wg.Done()
	if job.Friendly != "" {
		job.Progress(job.Friendly)
	}

	os.RemoveAll(job.Root())
}
Beispiel #3
0
func (k *Kindlegen) Process(job J.Job) {
	job.Progress("Optimizing for Kindle...")

	defer k.wg.Done()
	if err := writeHTML(job); err != nil {
		k.error(job, err.Error())
		return
	}

	cmd := exec.Command(k.binary, []string{job.HTMLFilename()}...)
	cmd.Dir = job.Root()
	out, err := cmd.CombinedOutput()
	if !fileExists(job.MobiFilePath()) {
		k.error(job, "failed running kindlegen: %s {output=%s}", err, out)
		return
	}

	job.Progress("Optimization complete...")
	k.Output <- job
}