如何下載 YouTube 私人影片 (使用 youtube-dl 或 ytl-dp)

本站搬家到GitHub了, 新網誌是 https://dennys.github.io/tw/doc/software/download-youtube-private-video/

前言

YouTube 預設是不能讓人下載影片的, 即使是你自己上傳的影片也是一樣. 然後我的影片大多都設成私人, 就更沒辦法用一堆線上工具下載了. 研究了一下兩年前曾被 GitHub 下架的 youtube-dl, 看來他支援下載私人影片 (不需要帳號密碼, 用 cookie).

工具準備

需要以下幾樣工具

  1. youtube-dl 或是 ytl-dp
  2. cookie 工具, 我是用 Get cookies.txt 這個 Chrome extension
  3. FFmpeg, 轉檔用

1. 準備 cookie

既然這是私人影片, 就會卡權限, 因此要準備 cookie. (注意: 這個套件不會去抓無痕模式的 cookie). 安裝好後, 連上 youtube.com, 然後 export 檔案出來就好. 預設他取的名字會是 youtube.com_cookies.txt, 這邊就不修改檔案名稱.

2. 使用 youtube-dl 下載

使用如下指令就可以下載檔案了

youtube-dl.exe --format bestvideo+bestaudio --limit-rate 2M --cookies=youtube.com_cookies.txt https://www.youtube.com/watch?v=********/

要注意的是, 如果沒有 FFmpeg, youtube-dl 就不會合併檔案, 最後就會有一個影片(mp4), 一個聲音 (m4a), 得要再另外 merge, 很麻煩, 如下圖.

因此, 直接在下載參數指定 FFmpeg 的目錄位置, 這樣在下載完後, 他就會去呼叫 FFmpeg 執行合併檔案的動作.

youtube-dl.exe --ffmpeg-location C:\bin\ffmpeg\bin --format bestvideo+bestaudio --limit-rate 2M --cookies=youtube.com_cookies.txt https://www.youtube.com/watch?v=********/

如下, 他會把 mp4/m4a 合併成一個 mp4 檔案, 然後把原來的檔案刪除.

3. 使用 youtube-dl 下載

YT-DLP 是 youtube-dl 的一個 fork, 他自己的官方說明是 “A youtube-dl fork with additional features and fixes", 兩者的指令也都差不多, 試用了一下也沒甚麼問題, 只是下載完是 .mkv

如何設定 Android 零打擾的時間長度

本站搬家到GitHub了, 新網誌是 https://dennys.github.io/tw/doc/android/android-do-not-disturb/

本站搬家到GitHub了, 新網誌是 https://dennys.github.io/tw/doc/android/android-do-not-disturb/

Android 可以從快速設定來開關零打擾, 但預設只能開和關, 常常開了後就忘了關了.

如果要調整零打擾的長度, 可從這裡修改: 設定->通知->零打擾->從快速設定開啟時的持續時間長度

預設值是"直到你關閉為止", 因此他就只能開和關. 我是把它改成"每次都詢問"

改過之後再看快速設定, 右邊就多了一個箭頭, 按下去就會有選項

這裡就可以設定你要零打擾的時間長度 (以小時為單位), 或是直接指定時間.

Android 使用小技巧相關文章

將 Gmail 的通知改成可以直接刪除

本站搬家到GitHub了, 新網誌是 https://dennys.github.io/tw/doc/android/gmail-notify-delete-archive/

Gmail 的通知, 預設是可以在通知的地方選"封存"或"回覆", 但其實可以修改.

打開 Gmail App, 進入一般設定, 修改預設的電子郵件通知動作, 預設是"封存", 把它改成刪除.

修改完後, 就可以在收到 Gmail 通知時, 直接刪除信件.

如果可以讓封存和刪除都出來就更好了.

Android 使用小技巧相關文章

Google Maps 音樂接藍牙, 語音不接

本站搬家到 GitHub 了, 新網址是 https://dennys.github.io/tw/doc/android/google-maps-bluetooth-voice-music/

不知道為甚麼, 手機接一般藍牙喇叭都不會延遲, 但接車機就會延遲, 而且延遲時間會愈來愈長. 聽音樂是還好, 但是導航語音延遲太長就是個問題了, 可能地方都過了才聽到聲音.

後來找到的解法是, 設定不要"透過藍牙撥放語音", 這樣就可以了. 當有導航時, 車上的音樂 (從手機的藍牙過來) 會暫停, 然後導航語音是直接從手機出來. 要注意的是, 導航音量可能要調大聲一點.

Android 使用小技巧相關文章

Use GitLab to do .NET 4.X CI/CD

This site is moved to GitHub, please visit the new URL: https://dennys.github.io/en/doc/devops/gitlab-dotnet4-ci-cd/

This site is moved to GitHub, please visit the new URL: https://dennys.github.io/en/doc/devops/gitlab-dotnet4-ci-cd/

This site is moved to GitHub, please visit the new URL: https://dennys.github.io/en/doc/devops/gitlab-dotnet4-ci-cd/

Precondition

  1. You already have a GitLab (GitLab SaaS or GitLab self managed)
  2. You want to build .NET 4.X, if you want to build .NET core or .NET 5 or above, you can use docker to run GitLab Runner.

Step 1 – Install Git client

Download and install Git for Windows. Portable version is ok, but because Git Runner is a Windows service, please add git.exe into PATH.

Step 2 – prepare .NET build environment

Download and install Visual Studio. (Please let me know if I can build a .NET build environment without Visual Studio, thanks.)

Step 3 – Install GitLab Runner

  1. Download GitLab Runner
  2. Rename gitlab-runner-windows-amd64.exe to gitlab-runner.exe
  3. Get the token to run GitLab Runner
  4. Generate GitLab Runner configuration file (config.toml)
    1. Run the command gitlab-runner.exe register --url https://gitlab.com/ --registration-token $REGISTRATION_TOKEN
  5. Modify config.toml
    1. Because Gitlab Runner doesn’t suppoer Windows shell after version 13, you need to use PowerShell. If you use Power Shell, please open config.toml and rename ‘pwsh’ to ‘powershell’. (If you use Power Shell Core, you don’t need to do anything)
    2. If you use a portable Git, you need to modify $env:Path of PowerShell.
    3. If you find your log is garbled (ex: your Windows server is not English version), please add “chcp 65001″ to change the encoding to UTF-8.
  6. Register GitLab Runner as a Windows service and start it.
    1. Run the command gitlab-runner install to install as a Windows service.
    2. Run the command gitlab-runner start to start the service.
  7. config.toml sample => remember, if you modify the file, please execute gitlab-runner.exe restart to restart GitLab runner.
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "GitLab Runner 007"
  url = "https://gitlab.com/"
  token = "******************"
  executor = "shell"
  shell = "powershell"
  pre_clone_script = """
      chcp 65001
      $env:Path += ";C:\\Gitlab\\PortableGit\\cmd"
  """
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

If you always see the Credential Helper Selector, please choose “no helper" and “Always use this from now on".

Step 4 – Write .gitlab-ci.yml

Edit .gitlab-ci.yml

.gitlab-ci.yml sample

stages:
    - build
    - test

build:
    stage: build
    script:
        - "dotnet build"
    artifacts:
      paths:
        - .\test

test:
    stage: test
    script: 
        - "dotnet test"

Step 5 – Start to build/test/deploy code (local machine)

Change directory to the location of .gitlab-ci.yml and execute this command

gitlab-runner.exe exec shell build

Step 6 – Start to test CI/CD (local machine)

If everything is ok, you can commit .gitlab-ci.yml and GitLab should run it automatically.

SAST (Static Application Security Testing)

GitLab can check your source code for known vulnerabilities, unfortunately, it only support Linux container, Windows containers are not yet supported. (reference: https://docs.gitlab.com/ee/user/application_security/sast/)

IFTTT 自動發 LINE 訊息 (免寫程式) – 以美元匯率為例

本站搬家到 GitHub 了, 新網址是 https://dennys.github.io/tw/doc/ifttt/line-robot-send-currency-exchange-rate-ifttt/

需求

用 LINE Bot 機器人每天自動發一個 LINE 訊息到群組, 要包含以下資訊.

  1. 匯率
  2. 一些連結到各銀行的匯率網站
  3. 一些匯率的歷史圖表

做法: 使用 IFTTT

IFTTT 是個免費的服務, 他的名字是 if this then that 的縮寫. 以這個應用來講, 我們要的是, IF 拿到一個匯率, THEN 發一個 LINE 訊息, 作法如下:

1. 在 IFTTT 建立一個新的 Applet

2. 新增一個 “If This"

3. 選擇 “Finance" service, 這個服務目前是由 Yahoo 提供的

4. 選擇"Today’s exchange rate report"

5. 在這裡輸入你需要的幣別和通知 (發 LINE) 的時間

6. 新增一個 “Then That"

7. 選擇 “LINE" service

8. 目前他只有一個功能就是 Send message, 就選這個

9.1 這時 IFTTT 會需要取得和 LINE 做整合的權限, 請選 Connect

9.2 這裡請使用 LINE 的帳號密碼登入

9.3 這時請回到手機上輸入認證碼, 權限就會開通了

以上 9.1~9.3 的部分只有第一次和 IFTTT 整合需要, 以後就不需要這個動作了.

10. LINE, 建立一個群組, 譬如我這裡的 TEST1, 然後把 LINE Notify 加進這個群組

11. 設定好你要發訊息的群組 (Recipient) 還有內容

12. 之後 IFTTT 就會自動每天發訊息了

注意

  1. IFTTT 好像沒辦法手動 trigger, 而且每天只會發一次, 所以每次修改完, 得等第二天才知道結果, 這個不像 Zapier 可以直接測試, 得再看看有沒有好的解法.
  2. 似乎只能發到群組, 他雖然有個 1 對 1 的訊息, 但我發到那個是沒用的
  3. 如果沒有把 LINE Notify 加到群組, 他就會發個訊息告訴你

實際範例 (LINE)

設定好後, 每天在你設定的時間, 就會收到一個 LINE 訊息 (實測是會有 1~2 分鐘的延遲)

實際範例 (手機通知)

其實很方便, 每天就會有個手機通知, 想看細節再點連結進去.

實際範例 (電腦版 LINE 的截圖)

IFTTT

這是這個 IFTTT applet 的連結: https://ifttt.com/applets/pC2DyG9z-line

Use IFTTT to send currency exchange rate mail daily

Requirement

I want to have a daily mail including currency exchange rate information.

  • Mail subject: include the exchange rate in the mail subject.
  • Mail content:
    1. Has some links to banks’ exchange rate page.
    2. Include some exchange rate history chart.

Solution: use ifttt.com

  1. Create a new Applet on IFTTT

2. Add a new “If This"

3. Choose “finance" service

4. Choose “Today’s exchange rate report"

5. Choose the input/output currency and trigger time.

6. Add a new “Then That"

7. Choose a “gmail" service

8. If you just want to send yourself an email, you can click the right button. If you want to send to several recipients, you can click left button.

9. This is an example to send your self an email.

9.1 This is my email body

As of {{CheckTime}}, 1 {{InputCurrency}} equals {{ExchangeRate}} {{OutputCurrency}}.<br>
<br>
via {{InfoUrl}}

<b>美元匯率:</b>
<ul><li>
<a href="https://rate.bot.com.tw/xrt?Lang=zh-TW">即時</a>(台銀)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/day/USD">當日</a>(台銀)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1W">1周</a>(XE)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1M">1個月</a>(XE)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/ltm/USD">3個月</a>(台銀)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/l6m/USD">6個月</a>(台銀)
</li><li>
<a href="https://rate.bot.com.tw/xrt/quote/l1y/USD">1年</a>(台銀)&nbsp;
<a href="https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/exchange-rate-chart?Currency=USD/TWD">1年</a>(玉山)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1Y">1年</a>(XE)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/l3y/USD">3年</a>(台銀)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=5Y">5年</a>(XE)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=10Y">10年</a>(XE)&nbsp;
<a href="https://fxtop.com/en/historical-exchange-rates.php?A=1&C1=USD&C2=TWD&DD1=&MM1=&YYYY1=&B=1&P=&I=1&DD2=03&MM2=03&YYYY2=2099&btnOK=Go%21">1983~現在</a>(FXTOP)&nbsp;
</li><li>
<a href="https://historical.findrate.tw/USD/">1個月+1年+10年</a>(FindRate)
</li></ul><br/>

<b>2022/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2022&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2021/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2021&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2020/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2020&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2000/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2000&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>

Mail result

IFTTT

This is my IFTTT applet: https://ifttt.com/applets/SxPJ2fpv-

About the exchange rate history chart

I only find 2 websites provides exchange rate chart to embed in the mail content.

  1. https://fxtop.com/, it provides PNG format chart, I already include it in my IFTTT applet.
  2. https://www.currencyconverterrate.com/, it provides SVG format chart (ex: https://www.currencyconverterrate.com/currencycharts/usd/usd-twd-exchange-rates-history-chart-7-day.svg), but I cannot find a solution to show SVG in gmail. If you find a solution, please let me know, thanks.

Android 移除 Root 和 Magisk

本站搬家到 GitHub 了, 新網址是 https://dennys.github.io/tw/doc/android/android-remove-root-magisk/

注意: 系統刷機有一定的風險, 可能導致手機無法開機和失去保固, 資料還會被清空, 執行前請先三思!!!

注意: 系統刷機有一定的風險, 可能導致手機無法開機和失去保固, 資料還會被清空, 執行前請先三思!!!

注意: 系統刷機有一定的風險, 可能導致手機無法開機和失去保固, 資料還會被清空, 執行前請先三思!!!

====================================================================

在上次這篇 https://dennys.wordpress.com/?p=305 有說明如何修改系統設定檔, 修改完後, 其實就不需要 Root 了, 因此可以 UnRoot. 方法如下:

1. 將手機重開, 並同時按下 電源+音量下鍵進入 bootloader 模式

2. 用 fastboot 刷回原始的 boot.img

fastboot boot boot.img

2.1 其實 Magisk 有這個功能刷回原始的 boot.img

2.2 但我實測按下還原原始映像檔是沒作用的, 所以只好自己刷

3. 刷回原來的 boot.img 之後, 絕大多數 App 都可以用了, 不過實測發現沒有移除 Magisk, 還是有某些 App 譬如 Costco 或國泰世華銀行無法使用, 所以最後還是把 Magisk 移除. 但手機還是維持在 Unlock 狀態.

Android 改機系列相關文章