Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plugins.afreeca: support metadata#5849

Merged
bastimeyer merged 6 commits into
streamlink:masterfrom
B4TT3RY:plugins/afreeca/support-metadata
Feb 20, 2024
Merged

plugins.afreeca: support metadata#5849
bastimeyer merged 6 commits into
streamlink:masterfrom
B4TT3RY:plugins/afreeca/support-metadata

Conversation

@B4TT3RY

@B4TT3RY B4TT3RY commented Feb 20, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown

great thanks! you are so fast!!!

@bastimeyer

bastimeyer commented Feb 20, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@bastimeyer

Copy link
Copy Markdown
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

B4TT3RY commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown

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

B4TT3RY commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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