Skip to content

plugins.afreeca: support metadata #5849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

B4TT3RY
Copy link
Contributor

@B4TT3RY B4TT3RY commented Feb 20, 2024

Resolves: #5813

I don't know if it's right to handle it this way.
Nickname and title written in Korean are displayed as Unicode.
I'm not very familiar with python so I don't know how to handle this.

{
  "plugin": "afreeca",
  "metadata": {
    "id": "ecvhao",
    "author": "\uc6b0\uc641\uad73",
    "category": null,
    "title": "\uc774\ub2c8\uc15cD 2\uae30 \ub05d\uae4c\uc9c0 \ubcf4\ub294 \ub0a0"
  },
  ...
}

@NormanMises
Copy link

great thanks! you are so fast!!!

@bastimeyer
Copy link
Member

bastimeyer commented Feb 20, 2024

I'm not very familiar with python so I don't know how to handle this.

No problem... Let me give some assistance.

The plugin isn't very well maintained and its code is rather old. Your changes are fine for a quick fix (we don't have to refactor/rewrite the plugin for this), apart from two issues:

  1. Instead of accessing the JSON data keys like json["..."], use json.get("..."), so no KeyError will get raised if the data is missing (the validation schema defines them as optional).
  2. Another issue could be if the JSON data values are set to null, so it'd be better for this non-essential data to be validated as validate.any(str, None) instead of just str.

@bastimeyer bastimeyer added the plugin enhancement A new feature for a working Plugin label Feb 20, 2024
@bastimeyer
Copy link
Member

Btw, _get_channel_info() does only get called once, so it's probably better to apply the plugin metadata in _get_streams() after all checks have been performed, just before the streams get returned.

@bastimeyer
Copy link
Member

Checking the metadata of a random channel from your branch:

$ streamlink 'https://play.afreecatv.com/jjllyy/255329138' -j | jq .metadata
{
  "id": "jjllyy",
  "author": "박수박",
  "category": null,
  "title": "콜롬비아 빈민가 x 행배"
}

id must be a unique value. Using the broadcast number should be fine.

@bastimeyer
Copy link
Member

I meant changing it to the bno, which should be unique, right?

@bastimeyer
Copy link
Member

Using the broadcast number from the JSON data is also fine...

Please also add the metadata to the plugin module metadata at the top:

diff --git a/src/streamlink/plugins/afreeca.py b/src/streamlink/plugins/afreeca.py
index 364dc6fb..22ee99f0 100644
--- a/src/streamlink/plugins/afreeca.py
+++ b/src/streamlink/plugins/afreeca.py
@@ -2,6 +2,9 @@
 $description TV and live video game broadcasts, artist performances and personal daily-life video blogs & shows.
 $url play.afreecatv.com
 $type live
+$metadata id
+$metadata author
+$metadata title
 """
 
 import logging

@B4TT3RY
Copy link
Contributor Author

B4TT3RY commented Feb 20, 2024

BJID is also unique. BNO is updated every time the streamer turns on the broadcast.

omg I made a mistake with this commit...

@bastimeyer
Copy link
Member

Thanks, should be fine now...

Plugin metadata is properly documented:
https://deploy-preview-5849--streamlink.netlify.app/plugins#afreeca

merging...

@bastimeyer bastimeyer merged commit 881eedc into streamlink:master Feb 20, 2024
@NormanMises
Copy link

Sorry, but there's a suggestion, can you add the English username of the streamer to the metadata? It's "jjllyy", and I want to use the English name as the file name for easy identification (I don't know Korean), and this English name is also unique

@B4TT3RY
Copy link
Contributor Author

B4TT3RY commented Feb 20, 2024

Sorry, but there's a suggestion, can you add the English username of the streamer to the metadata? It's "jjllyy", and I want to use the English name as the file name for easy identification (I don't know Korean), and this English name is also unique

How about sideloading a modified plugin or using an English ID based on URL?
Looking at the docs, the id variable is The unique ID of the stream, e.g. an internal numeric ID or randomized string. It says.

@NormanMises
Copy link

Sorry, but there's a suggestion, can you add the English username of the streamer to the metadata? It's "jjllyy", and I want to use the English name as the file name for easy identification (I don't know Korean), and this English name is also unique对不起,但有一个建议,你能将主播的英文用户名添加到元数据中吗?是“jjllyy”,我想用英文名作为文件名,方便识别(我不懂韩文),这个英文名也是唯一的

How about sideloading a modified plugin or using an English ID based on URL?旁加载修改后的插件或使用基于 URL 的英文 ID 怎么样? Looking at the docs, the id variable is The unique ID of the stream, e.g. an internal numeric ID or randomized string. It says.查看文档, id 变量是 The unique ID of the stream, e.g. an internal numeric ID or randomized string. It says。

OK, just finish. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin enhancement A new feature for a working Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.afreeca: Support metadata
3 participants