Coder Social home page Coder Social logo

OPML via CI about blogs HOT 6 CLOSED

liyishuai avatar liyishuai commented on September 1, 2024
OPML via CI

from blogs.

Comments (6)

taoky avatar taoky commented on September 1, 2024 1

5acf240

@libreliu

from blogs.

taoky avatar taoky commented on September 1, 2024

糊了一个生成脚本 https://github.com/ustclug/blogs/blob/master/opml.py

from blogs.

libreliu avatar libreliu commented on September 1, 2024

糊了一个生成脚本 https://github.com/ustclug/blogs/blob/master/opml.py

我用的 Thunderbird 102.6.1 (Windows 10),似乎生成的 OPML 文件并不能成功导入 Thunderbird (会提示“文件 opml.opml 似乎不是一个有效的 OPML 文件。”)

另外,在 Windows (& cp936)下默认字符编码是 gbk,可能最好在 open 那里指定一下

diff --git a/opml.py b/opml.py
index e85f368..6309d85 100644
--- a/opml.py
+++ b/opml.py
@@ -17,7 +17,7 @@ def check(rssurl):
 def main(args):
     contents = []
     # 1. Parse README.md and get the list of links
-    with open("./README.md") as f:
+    with open("./README.md", encoding="utf-8") as f:
         for line in f:
             if line.startswith("|"):
                 try:

from blogs.

taoky avatar taoky commented on September 1, 2024

Thunderbird 导入不了的原因是 Windows 下 python opml.py --thunderbird > opml.opml 得到的 opml.opml 是 UTF-16 的文件,但是 Thunderbird(至少在 Linux 下)只吃 UTF-8。

open() 的 encoding 已经在 898f537 加了。

from blogs.

taoky avatar taoky commented on September 1, 2024

加上了 sys.stdout.reconfigure(encoding='utf-8') 之后,Python 在 Windows console 下文件重定向的行为是:

  • cmd.exe: UTF-8
  • powershell.exe(自带版本): UTF-16
  • PowerShell 6+: 根据这里的说法是 UTF-8

所以还是只能把脚本改成默认输出文件了。

from blogs.

libreliu avatar libreliu commented on September 1, 2024

5acf240

@libreliu

现在在 Windows 10 + cp936 下面可以啦,感谢

from blogs.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.