11

把 YouTube 的 Dislike 數字弄回來

 2 years ago
source link: https://blog.gslin.org/archives/2021/11/28/10439/%e6%8a%8a-youtube-%e7%9a%84-dislike-%e6%95%b8%e5%ad%97%e5%bc%84%e5%9b%9e%e4%be%86/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

把 YouTube 的 Dislike 數字弄回來

最近 YouTube 也在搞事,把 Dislike 的數字拔掉了,後來在 Greasy Fork 上面找了一下,看到有兩套方法可以把數字補回來。

第一套是「Return YouTube Dislike」這個方法,從程式碼裡面可以看到是透過 API 拉出來的:

function setState() {
  cLog('Fetching votes...');
 
  doXHR({
    method: "GET",
    responseType: "json",
    url:
      "https://return-youtube-dislike-api.azurewebsites.net/votes?videoId=" +
      getVideoId(),
    onload: function (xhr) {
      if (xhr != undefined) {
        const { dislikes, likes } = xhr.response;
        cLog(`Received count: ${dislikes}`);
        setDislikes(numberFormat(dislikes));
        createRateBar(likes, dislikes);
      }
    },
  });
}

這個 API 後面應該是接 Videos: getRating 拉資料出來,但畢竟不是直接打 YouTube API (比較麻煩,需要每個使用者自己申請 API token),這樣就有隱私的疑慮了...

另外一套是「Show Youtube Dislike Count」,看了裡面程式碼發現他是用 averageRating 反推回來:

if (likeCount >= 0) {
    const r = data.playerResponse.videoDetails.averageRating;
    const dislikeCount = Math.round(likeCount * (5 - r) / (r - 1));

    ShowDislikes(likeCount, dislikeCount);
}

不過作者有點偷懶,這邊在等待頁面生成單純用 100ms 等頁面出現,有時候還是會有 race condition (就是後面還是讀不到 XDDD),如果懶的大修的話可以改成 1000ms 混過去,降低一些機率:

while (!isLoaded) {
    await Sleep(100);
}

另外數字很大的時候會稍微不準,但也算夠用了,先暫時用這套來頂著了...

Related

在 Gmail 裡面展開 GitHub 信件連結的 Userscript

從以前用 Subversion 就有習慣用 e-mail 收 diff log (內建的 hook 就有這個功能)。後來有了 Gmail 就更方便了,畢竟搜尋是 Google 的強項,另外一方面 Gmail 也是目前少數可以完全用鍵盤操作的 e-mail client。 現在用 Git 與 GitHub 平台讓這件事情麻煩不少,得透過 webhook + API 自己包出來,目前折衷的方法是收 GitHub 的通知信 (但是沒有 diff log),然後寫個 Userscript,在按下 i 之後會把 GitHub 通知信裡的連結全部點開:「open-github-links-in-gmail」。 寫的很簡單... 最花時間反而是因為 hotkey 都被吃掉了,要測出哪個鍵還沒被用掉。

May 14, 2019

In "Browser"

AWS 推出 CloudWatch Metric Streams

AWS 推出了 CloudWatch Metric Streams,把 CloudWatch Metric 的資料往 Kinesis Data Firehose 裡面丟:「CloudWatch Metric Streams – Send AWS Metrics to Partners and to Your Apps in Real Time」。 其中一個賣點是即時性比用 API 去拉好很多: In order to make it easier for AWS Partners and others to gain access to CloudWatch metrics faster and at…

April 1, 2021

In "AWS"

音樂著作的授權架構

在 TorrentFreak 上看到「YouTube Copyright Complaint Kills Harvard Professor's Copyright Lecture (Update)」這篇文章提到了 YouTube 下架了「William Fisher, CopyrightX: Lecture 3.3, The Subject Matter of Copyright: Music」這部影片。 有兩件事情吸引我,第一件是,這是哈佛法學院的教授 William Fisher 的課程在說明音樂產業的著作權以及授權架構的線上影片,被 SME (i.e. Sony) 透過 YouTube 的 ContentID 以侵犯版權給下架了... XDDD (瞬間把板凳給拉出來坐著等) 第二件事情是在這個影片恢復後跑去看而發現的,發現描述音樂產業的授權模式講的相當清楚 (以美國的觀點),尤其當你身在這個產業裡 (yeah yeah),要因為這些授權架構不斷的改變,去修改現有的資料庫設計以配合授權架構,就會更有感覺了。 這個影片另外一個值得讀的地方在於他有手工翻譯的英文字幕可以看,有興趣看這個產業裡的各種複雜的授權架構的人,絕對值得觀看這 24 分鐘的影片:

February 22, 2016

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on November 28, 2021November 28, 2021Categories Computer, Murmuring, Network, SoftwareTags api, dislike, like, number, rate, score, userscript, userscripts, youtube

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comment

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK