-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcook.php
More file actions
executable file
·61 lines (50 loc) · 1.65 KB
/
Copy pathcook.php
File metadata and controls
executable file
·61 lines (50 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
//标题
$title = $_POST['title'];
$author = $_POST['author'];
$urls = $_POST['url'];
$blog = array();
$file_name = time();
$file_name_json = $file_name.'.json';
$file = fopen($file_name_json,"w");
foreach ($urls as $key => $value) {
$blog['title'] = $value;
$blog['url'] = $value;
fwrite($file, json_encode($blog)."\n");
}
fclose($file);
$recipe = <<<EOT
# -*- coding:utf-8 -*-
from calibre.web.feeds.recipes import BasicNewsRecipe
import json
class Git_Pocket_Guide(BasicNewsRecipe):
title = '$title'
description = '$author'
cover_url = 'http://upload.jianshu.io/daily_images/images/-yxy6Bo7FmVnyPszqYdF.jpg'
no_stylesheets = True
keep_only_tags = [{ 'class': 'article' }]
def read_json(self):
f = open('/www/web/html2mobi/$file_name_json','r')
lines = []
for line in f:
s = {}
t = json.loads(line)
s['title'] = t['title']
s['url'] = t['url']
lines.append(s)
f.close
return lines
def parse_index(self):
links = self.read_json()
ans = [('$title', links)]
return ans
EOT;
$file_name_recipe = $file_name.'.recipe';
$recipe_handle = fopen($file_name_recipe,"w");
fwrite($recipe_handle, $recipe);
fclose($recipe_handle);
header("Content-type: text/html; charset=utf-8");
$file_name_epub = $file_name.".epub";
exec('/home/calibre/calibre/ebook-convert '. $file_name_recipe .' '. $file_name_epub);
echo "您的电子书新鲜出炉,点击下载<a href= '/".$file_name_epub."''>".$file_name_epub."</a>";
?>