From 78760ab08d1d2ca51004934ac8ff690be38fd7ce Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 11 Jan 2018 16:59:47 +0800 Subject: + fix --- _posts/2017/12/movies.rst | 76 +++++++++++++++++++++++++++++++++++++++++++++++ _posts/2017/movies.rst | 74 --------------------------------------------- rss.py | 73 +++++++++++++++++++++++---------------------- 3 files changed, 113 insertions(+), 110 deletions(-) create mode 100644 _posts/2017/12/movies.rst delete mode 100644 _posts/2017/movies.rst diff --git a/_posts/2017/12/movies.rst b/_posts/2017/12/movies.rst new file mode 100644 index 0000000..94ecee5 --- /dev/null +++ b/_posts/2017/12/movies.rst @@ -0,0 +1,76 @@ +:orphan: + +.. _2017movie: + + +2017观影记录 +=================== + +:Publish Date: 2010-01-01 + +2017年马上就结束了。掐指一算,2017年看了好多电影。包括线上和线下电影院的。 + +线下电影院观影记录(按时间顺序,以中国大陆上映时的片名为准): + +- `星球大战外传:侠盗一号 `__ (Rogue One: A Star Wars Story) +- `太空旅客 `__ (Passengers) +- `降临 `__ (Arrival) +- `极限特工:终极回归 `__ (xXx: The Return of Xander Cage) +- `生化危机6:终章 `__ (Resident Evil: The Final Chapter) +- `金刚狼3:殊死一战 `__ (Logan) +- `攻壳机动队 `__ (Ghost in the Shell) +- `速度与激情8 `__ (The Fate of the Furious) +- `拆弹专家 `__ +- `大护法 `__ +- `战狼2 `__ +- `星际特工:千星之城 `__ (Valérian et la Cité des mille planètes) +- `看不见的客人 `__ (Contratiempo) +- `英伦对决 `__ (The Foreigner) +- `天才枪手 `__ (ฉลาดเกมส์โกง) +- `王牌特工2:黄金圈 `__ (Kingsman: The Golden Circle) +- `全球风暴 `__ (Geostorm) +- `东方快车谋杀案 `__ (Murder on the Orient Express) +- `雷神3:诸神黄昏 `__ (Thor: Ragnarok) +- `追捕 `__ +- `至暗时刻 `__ (Darkest Hour) +- `寻梦环游记 `__ (Coco) +- `至爱梵高·星空之谜 `__ (Loving Vincent) +- `芳华 `__ + +线上观影记录(包括BT下载以及Netflix,包括电影/纪录片/部分美剧,不完全): + +- `Blade Runner `__ (1982) +- `Blade Runner 2049 `__ +- `Love Actually `__ +- `World War Z `__ +- `Dunkirk `__ +- `Everst `__ +- `霸王别姬 `__ +- `Titanic `__ +- `隧道 `__ (터널) +- `London Has Fallen `__ +- `出租车司机 `__ (택시운전사) +- `Ocean's Eleven `__ +- `Ocean's Twelve `__ +- `Shooter `__ +- `Knight Day `__ +- `2001: A Space Odyssey `__ +- `Minority Report `__ +- `Deep Impact `__ +- `Area 51 `__ +- `San Andreas `__ +- `I, Origin `__ +- `Particle Fever `__ +- `City 40 `__ +- `Stranger Things `__ +- `House Of Cards `__, Season 1 + +现在回忆一下,很多电影的质量其实很一般,属于看完之后走出电影院差不多就能忘记剧情的那种。这种电影很多都是所谓的「商业大片」,追求特效和画面,完全不考虑剧情的质量和观众的观影感受。 + +简单分析了一下,线下观影的统计 + +.. image:: ../../../_static/img/2017movie.png + :alt: 2017movie + :align: center + +6月居然一部都没看,是因为工作太饱和了还是因为没有好看的电影呢? \ No newline at end of file diff --git a/_posts/2017/movies.rst b/_posts/2017/movies.rst deleted file mode 100644 index 10fcbc3..0000000 --- a/_posts/2017/movies.rst +++ /dev/null @@ -1,74 +0,0 @@ -:orphan: - -.. _2017movie: - -2017观影记录 -=================== - - -2017年马上就结束了。掐指一算,2017年看了好多电影。包括线上和线下电影院的。 - -线下电影院观影记录(按时间顺序,以中国大陆上映时的片名为准): - -- `星球大战外传:侠盗一号 `__ (Rogue One: A Star Wars Story) -- `太空旅客 `__ (Passengers) -- `降临 `__ (Arrival) -- `极限特工:终极回归 `__ (xXx: The Return of Xander Cage) -- `生化危机6:终章 `__ (Resident Evil: The Final Chapter) -- `金刚狼3:殊死一战 `__ (Logan) -- `攻壳机动队 `__ (Ghost in the Shell) -- `速度与激情8 `__ (The Fate of the Furious) -- `拆弹专家 `__ -- `大护法 `__ -- `战狼2 `__ -- `星际特工:千星之城 `__ (Valérian et la Cité des mille planètes) -- `看不见的客人 `__ (Contratiempo) -- `英伦对决 `__ (The Foreigner) -- `天才枪手 `__ (ฉลาดเกมส์โกง) -- `王牌特工2:黄金圈 `__ (Kingsman: The Golden Circle) -- `全球风暴 `__ (Geostorm) -- `东方快车谋杀案 `__ (Murder on the Orient Express) -- `雷神3:诸神黄昏 `__ (Thor: Ragnarok) -- `追捕 `__ -- `至暗时刻 `__ (Darkest Hour) -- `寻梦环游记 `__ (Coco) -- `至爱梵高·星空之谜 `__ (Loving Vincent) -- `芳华 `__ - -线上观影记录(包括BT下载以及Netflix,包括电影/纪录片/部分美剧,不完全): - -- `Blade Runner `__ (1982) -- `Blade Runner 2049 `__ -- `Love Actually `__ -- `World War Z `__ -- `Dunkirk `__ -- `Everst `__ -- `霸王别姬 `__ -- `Titanic `__ -- `隧道 `__ (터널) -- `London Has Fallen `__ -- `出租车司机 `__ (택시운전사) -- `Ocean's Eleven `__ -- `Ocean's Twelve `__ -- `Shooter `__ -- `Knight Day `__ -- `2001: A Space Odyssey `__ -- `Minority Report `__ -- `Deep Impact `__ -- `Area 51 `__ -- `San Andreas `__ -- `I, Origin `__ -- `Particle Fever `__ -- `City 40 `__ -- `Stranger Things `__ -- `House Of Cards `__, Season 1 - -现在回忆一下,很多电影的质量其实很一般,属于看完之后走出电影院差不多就能忘记剧情的那种。这种电影很多都是所谓的「商业大片」,追求特效和画面,完全不考虑剧情的质量和观众的观影感受。 - -简单分析了一下,线下观影的统计 - -.. image:: ../../_static/img/2017movie.png - :alt: 2017movie - :align: center - -6月居然一部都没看,是因为工作太饱和了还是因为没有好看的电影呢? \ No newline at end of file diff --git a/rss.py b/rss.py index fbf70d1..faa004c 100644 --- a/rss.py +++ b/rss.py @@ -1,68 +1,69 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Created by i@BlahGeek.com at 2015-07-30 - import os -import argparse -import yaml - import jinja2 +import glob +from bs4 import BeautifulSoup -class FilePathLoader(jinja2.BaseLoader): - """ Custom Jinja2 template loader which just loads a single template file """ +class FilePathLoader(jinja2.BaseLoader): def __init__(self, cwd): self.cwd = cwd def get_source(self, environment, template): - # Path filename = os.path.join(self.cwd, template) - # Read try: with open(filename, 'r') as f: contents = f.read() except IOError: raise jinja2.TemplateNotFound(filename) - # Finish - uptodate = lambda: False - return contents, filename, uptodate + return contents, filename, lambda: False def render_template(cwd, template_path, context): env = jinja2.Environment(loader=FilePathLoader(cwd)) + return env.get_template(template_path).render(context) - return env \ - .get_template(template_path) \ - .render(context) + +def _remove_attrs(soup): + for tag in soup.findAll(True): + tag.attrs = None + return soup def main(): - parser = argparse.ArgumentParser() - - parser.add_argument('--dir', default='.', help='Template directory') - parser.add_argument('--data', nargs='*', help='One or more YAML data file') - parser.add_argument('--template', help='Template file to process') - parser.add_argument('--body', help='Body content') - args = parser.parse_args() - - context = dict() - for data_f in args.data if args.data else []: - key, filename = data_f.split(':') - if filename: - context[key] = yaml.load(open(filename).read()) - else: - context[key] = {'_': True} - if args.body: - context['body'] = open(args.body).read() + + filenames = glob.glob("./_build/html/_posts/*/*/*.html") + print(filenames) + + posts = [] + + for p in filenames: + soup = BeautifulSoup(open(p), "html5lib") + body = soup.find_all("div", class_="body") + posts.append({ + "title": soup.title.string, + "body": body[0].text, + "date_rss": "", + "permalink": "/".join(p.split("/")[3:]) + }) + + context = { + "site": { + "name": "Hello World", + "url": "https://blog.jinwei.me", + "tagline": "Freedom is my birthright and I shall have it." + }, + "posts": posts + } return render_template( - args.dir, - args.template, + ".", + "all.rss.xml", context ) + if __name__ == '__main__': print(main()) -- cgit v1.2.3