Category Archives: macOS

macOS version of Twitter Image Saver

A few days ago, I wrote a Twitter image saver with Rust, but it's a cli application, which makes it not so easy for daily use (I have to type some command to start or stop it, also need to edit the JSON config file manually). Therefore I rewrote it in GUI (to be accurate, a status bar application) on macOS.

It would be pretty easy to set up, click the Settings menu, fill in the consumer key and secret, and then select the directory where you'd like to save the images. Finally, add some accounts (without @) you interested into the list! The total number and the total size of images saved for the current session will be displayed in the drop-down menu.

Furthermore, this application's icon is the combination plus some modifications of two original ones; they were made by Anton Kalashnyk and Fauzan Adiima.

The source code of this project is on my GitLab.

另一种方法获取 macOS 网易云音乐的正在播放

虽然标题里面写的是“另一种”,但是先前的方法其实不是我写的?而是来自可爱少女 Makito 的两篇 post ——

于是就看到了直接从 Mach 内核入手的方法,是賢い、かわいい Makito~!不过今天跑去 clone 代码下来尝试的时候似乎会 crash 的样子,毕竟距离上次 update 代码也过去了 9 个月左右了,猜想可能是网易云音乐有所修改导致(在我用别的方法尝试的时候,也是莫名 crash 了)

于是这里就写一个另一种获取 macOS 网易云音乐的正在播放的方法吧~

Continue reading 另一种方法获取 macOS 网易云音乐的正在播放

站名牌產生器(((o(*゚▽゚*)o)))

這個站名牌產生器算是超久之前寫的程式了,站名牌的樣式仿自 http://data.but.tw/eki/。在那個網站上還有超多別的城市的地鐵站名牌,然而這個網站並不能生成 SVG 格式的向量圖,其生成的圖片在清晰度上也有所欠缺,於是我就仿照著其中 6 個站名牌做了一點微小的工作~

雖然並不是鐵道廚,但是有些站名牌的確還蠻好看的,於是就做了一個 macOS 下可以生成站名牌 SVG 向量圖,以及可以儲存成縮放任意倍數 PNG 圖片的程式~要是有誰想改成網頁版的話,那就更好了233333

程式碼的話就在這裡啦 ➜ #/eki

下面再放幾張生成好的圖片吧~

Continue reading 站名牌產生器(((o(*゚▽゚*)o)))

Python 2.7 + Scripting Bridge 导出 iTunes Library 里音乐的 MetaInfo 与封面到 MongoDB

作为某个 Project 的一部分~(暂时不透露是什么,嘻嘻(⁎⁍̴̛ᴗ⁍̴̛⁎) ) 需要把 iTunes 里面的所有音乐的 MetaInfo 和封面导出到 MongoDB 中

MongoDB 上次已经已经在 Raspberry Pi 4 上编译部署好了~在 Raspberry Pi 4 上安装 64-bit MongoDB Server 服务

然后再配合很久以前玩过的 在 Python 里使用 Scripting Bridge 与 iTunes 交互,就可以达到目标了233333

当然需要注意的是,这里要使用的是 macOS 自带的 Python 2.7,因为 ScriptingBridge 只安装在了自带的 Python 2.7 里

真正代码的话,其实整体来说很简单,需要考虑的点是如何做到不重复写封面,因为——

  1. 目前 Scripting Bridge 与 iTunes 交互时,只能一首音乐一首音乐的依次遍历,不能直接按照专辑遍历
  2. 同一张专辑里,有的音乐可能包含多张封面
  3. 不同的专辑可能被我 assgin 过相同的封面

综合这几点考虑的话,那就只能每次拿到有封面的音乐之后,对它的每一张封面都计算 SHA256 摘要(这里暂且认为 SHA256 的空间足够大,不会产生碰撞),并在放进 global_sha256 前,检查是否已经有相同的 SHA256 存在其中。如果没有的话,才保存图片到磁盘中,并放到那首歌的 MetaInfo 中;如果在 global_sha256 中有的话,那么就再看那首歌的 MetaInfo 中有没有这个 SHA256(因为也许有人不小心添加了两张一样的封面到音乐里)。

在遍历完所有音乐之后,把这些 MetaInfo 写入到 JSON 文件中~(就像下面这样

{
  "album": "Cutie Panther", 
  "name": "夏、終わらないで。", 
  "artist": "BiBi (南條愛乃, Pile, 徳井青空)", 
  "cover": [
    "44f9b56091c7ca5b011cd9cb306eab21d4f854300c96347a0a7f3538cbeb9dcd-1"
  ], 
  "composer": "渡辺和紀", 
  "year": 0, 
  "sha256": [
    "44f9b56091c7ca5b011cd9cb306eab21d4f854300c96347a0a7f3538cbeb9dcd"
  ]
}

最后再导进 MongoDB 数据库就可以啦(当然需要安装一下 pymongo 库)~主要的就分为 2 个 stage ♪(´ε` )

python2.7 -m pip install --user pymongo
python2.7 iTunes.py -s 1
python2.7 iTunes.py --host raspberrypi.local -s 2
Continue reading Python 2.7 + Scripting Bridge 导出 iTunes Library 里音乐的 MetaInfo 与封面到 MongoDB

Write a Digital Clock on macOS

昨天打着打着电话,突然玲就问我,macOS 能不能同时显示两个数字时钟,于是我就找了一圈,DashBoard 上虽然可以显示两个,但是都是模拟时钟,而且玲也没买触摸板,在桌面和 DashBoard 之间切换不那么方便。

就计划帮她写一个,于是“产品经理玲”就发给我了一个 prototype (゚o゚;;

写,都可以写(x

Continue reading Write a Digital Clock on macOS