Skip to content
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

添加发送专栏的api #742

Open
z0z0r4 opened this issue Apr 12, 2024 Discussed in #741 · 50 comments
Open

添加发送专栏的api #742

z0z0r4 opened this issue Apr 12, 2024 Discussed in #741 · 50 comments
Labels
feature 新功能 good first issue 新的贡献者适合解决的问题 need 我要这个

Comments

@z0z0r4
Copy link
Collaborator

z0z0r4 commented Apr 12, 2024

Discussed in #741

Originally posted by adk23333 April 12, 2024
合并图文的议题

是暂时没时间添加还是这里面有坑,无坑的话,我去试试?

@z0z0r4 z0z0r4 added need 我要这个 good first issue 新的贡献者适合解决的问题 feature 新功能 labels Apr 12, 2024
@adk23333
Copy link

adk23333 commented Apr 12, 2024

https://api.bilibili.com/x/dynamic/feed/create/opus?csrf=&gaia_source=main_web&w_rid=&wts=
{
  "raw_content": "{\"ops\":[{\"insert\":\"test2233\\n\"},{\"attributes\":{\"class\":\"normal-img\"},\"insert\":{\"native-image\":{\"alt\":\"read-normal-img\",\"url\":\"https://article.biliimg.com/bfs/new_dyn/bcdecbbf01b……67389.jpg@.webp\",\"width\":410,\"height\":286,\"size\":81963,\"status\":\"loaded\"}}},{\"insert\":\"\\n\"}]}",
  "opus_req": {
    "upload_id": "3847……7433",
    "opus": {
      "opus_source": 2,
      "title": "test",
      "content": {
        "paragraphs": [
          {
            "para_type": 1,
            "text": {
              "nodes": [
                {
                  "node_type": 1,
                  "word": {
                    "words": "test2233",
                    "font_size": 17,
                    "style": {}
                  }
                }
              ]
            }
          },
          {
            "para_type": 2,
            "pic": {
              "style": 1,
              "pics": [
                {
                  "url": "https://article.biliimg.com/bfs/new_dyn/bcdecbbf01b……84767389.jpg",
                  "width": 410,
                  "height": 286,
                  "size": 80.0419921875
                }
              ]
            }
          },
          {
            "para_type": 1,
            "text": {
              "nodes": [
                {
                  "node_type": 1,
                  "word": {
                    "words": "\n",
                    "font_size": 17,
                    "style": {}
                  }
                }
              ]
            }
          }
        ]
      },
      "article": {
        "category_id": 15,
        "list_id": 0,
        "originality": 0,
        "reproduced": 0
      },
      "pub_info": {}
    },
    "scene": 12,
    "meta": {
      "app_meta": {
        "from": "create.article.web",
        "mobi_app": "web"
      }
    },
    "option": {
      "close_comment": 1
    }
  },
  "draft_id_str": "295560",
  "ts": 1712889307
}

发布专栏的接口

https://api.bilibili.com/x/article/creative/article/upcover?w_rid=&wts=

cover=data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdC……

上传专栏图片的

app上发布旧版专栏的话主要就这俩了吧

感觉要先实现一个专栏json的生成器

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

需要协助的话可以说下,我今天还有点空

@adk23333
Copy link

需要协助的话可以说下,我今天还有点空

说实话还没开始,今天休息hh

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

我顶多就只有周日了,暑假就真高三了...

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

member.bilibili.com/read/editor/#/web

在这里测试不错

{
    "ops": [
        {
            "attributes": {
                "color": "#60d837"
            },
            "insert": "test"
        },
        {
            "attributes": {
                "header": 2
            },
            "insert": "\n"
        },
        {
            "insert": "\ndwdwdaw"
        },
        {
            "attributes": {
                "list": "bullet"
            },
            "insert": "\n"
        },
        {
            "insert": "d4wad444444"
        },
        {
            "attributes": {
                "align": "right",
                "list": "bullet"
            },
            "insert": "\n"
        },
        {
            "insert": "dwdw"
        },
        {
            "attributes": {
                "align": "center"
            },
            "insert": "\n"
        },
        {
            "attributes": {
                "class": "cut-off"
            },
            "insert": {
                "cut-off": {
                    "type": "0",
                    "url": "https://i0.hdslb.com/bfs/article/0117cbba35e51b0bce5f8c2f6a838e8a087e8ee7.png"
                }
            }
        },
        {
            "attributes": {
                "italic": true,
                "link": "https://www.bilibili.com/video/BV1xr421b7YG?spm_id_from=333.1007.tianma.1-1-1.click"
            },
            "insert": "tql"
        },
        {
            "attributes": {
                "blockquote": true
            },
            "insert": "\n"
        },
        {
            "insert": "wdad\n"
        },
        {
            "attributes": {
                "class": "normal-img"
            },
            "insert": {
                "native-image": {
                    "alt": "read-normal-img",
                    "url": "https://article.biliimg.com/bfs/new_dyn/6e7d28ed54b3f32f8cb78f6fda21d70c558830935.jpg@.webp",
                    "width": 3840,
                    "height": 2160,
                    "size": 213769,
                    "status": "loaded"
                }
            }
        },
        {
            "insert": "\n"
        },
        {
            "attributes": {
                "blockquote": true
            },
            "insert": "\n"
        },
        {
            "insert": "\n"
        },
        {
            "attributes": {
                "class": "cut-off"
            },
            "insert": {
                "cut-off": {
                    "type": "5",
                    "url": "https://i0.hdslb.com/bfs/article/02db465212d3c374a43c60fa2625cc1caeaab796.png"
                }
            }
        },
        {
            "insert": "\n"
        },
        {
            "attributes": {
                "header": 2
            },
            "insert": "\n"
        },
        {
            "insert": "11"
        },
        {
            "attributes": {
                "color": "#ea0077"
            },
            "insert": "dw"
        },
        {
            "attributes": {
                "color": "#fff359"
            },
            "insert": "dw"
        },
        {
            "attributes": {
                "color": "#fff359",
                "italic": true
            },
            "insert": "dwdaw"
        },
        {
            "attributes": {
                "header": 2
            },
            "insert": "\n"
        },
        {
            "insert": "😅❤️❤️\n\n"
        },
        {
            "attributes": {
                "class": "cut-off"
            },
            "insert": {
                "cut-off": {
                    "type": "3",
                    "url": "https://i0.hdslb.com/bfs/article/db75225feabec8d8b64ee7d3c7165cd639554cbc.png"
                }
            }
        },
        {
            "insert": "\n"
        },
        {
            "attributes": {
                "strike": true,
                "italic": true
            },
            "insert": "dwadw"
        },
        {
            "attributes": {
                "strike": true,
                "bold": true
            },
            "insert": "dw"
        },
        {
            "attributes": {
                "header": 1
            },
            "insert": "\n"
        }
    ]
}

image

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

不提交就么有 paragraphs 字段,我多尝试提交几次...

{
    "raw_content": "{\"ops\":[{\"attributes\":{\"strike\":true,\"color\":\"#60d837\",\"bold\":true},\"insert\":\"test\"},{\"attributes\":{\"header\":2},\"insert\":\"\\n\"},{\"insert\":\"\\n\"},{\"attributes\":{\"italic\":true},\"insert\":\"dawhdhaw\"},{\"attributes\":{\"italic\":true,\"bold\":true},\"insert\":\"ohdouhhjkkkkkkk\"},{\"attributes\":{\"italic\":true},\"insert\":\"kkkkkkkkkkkkkkkkkkk\"},{\"attributes\":{\"color\":\"#73fdea\",\"italic\":true},\"insert\":\"kkkkkk\"},{\"attributes\":{\"italic\":true},\"insert\":\"kkkkkkkkk的娃娃对我打击和我觉得家里文化的\"},{\"attributes\":{\"strike\":true,\"italic\":true},\"insert\":\"交流和\"},{\"attributes\":{\"strike\":true,\"color\":\"#60d837\",\"italic\":true},\"insert\":\"挖掘\"},{\"attributes\":{\"strike\":true,\"italic\":true},\"insert\":\"了觉得我很了解啊好了大家好我立即回到老家记得和我交流活动链接和网络江湖大佬\"},{\"attributes\":{\"italic\":true},\"insert\":\"教我\"},{\"insert\":\"\\n测试\\nd4wad444444\"},{\"attributes\":{\"align\":\"right\",\"list\":\"bullet\"},\"insert\":\"\\n\"},{\"insert\":\"dwdw\"},{\"attributes\":{\"align\":\"center\"},\"insert\":\"\\n\"},{\"attributes\":{\"class\":\"cut-off\"},\"insert\":{\"cut-off\":{\"type\":\"0\",\"url\":\"https://article.biliimg.com/bfs/article/0117cbba35e51b0bce5f8c2f6a838e8a087e8ee7.png\"}}},{\"attributes\":{\"italic\":true,\"link\":\"https://www.bilibili.com/video/BV1xr421b7YG?spm_id_from=333.1007.tianma.1-1-1.click\"},\"insert\":\"tql\"},{\"insert\":\" 达瓦达瓦\"},{\"attributes\":{\"blockquote\":true},\"insert\":\"\\n\"},{\"insert\":\"wdad\\n\"},{\"attributes\":{\"class\":\"normal-img\"},\"insert\":{\"native-image\":{\"alt\":\"read-normal-img\",\"url\":\"https://article.biliimg.com/bfs/new_dyn/6e7d28ed54b3f32f8cb78f6fda21d70c558830935.jpg@.webp\",\"width\":3840,\"height\":2160,\"size\":213769,\"status\":\"loaded\"}}},{\"insert\":\"\\n\"},{\"attributes\":{\"blockquote\":true},\"insert\":\"\\n\"},{\"insert\":\"\\n\"},{\"attributes\":{\"class\":\"cut-off\"},\"insert\":{\"cut-off\":{\"type\":\"5\",\"url\":\"https://article.biliimg.com/bfs/article/02db465212d3c374a43c60fa2625cc1caeaab796.png\"}}},{\"insert\":\"\\n\"},{\"attributes\":{\"header\":2},\"insert\":\"\\n\"},{\"insert\":\"11\"},{\"attributes\":{\"color\":\"#ea0077\"},\"insert\":\"dw\"},{\"attributes\":{\"color\":\"#fff359\"},\"insert\":\"dw\"},{\"attributes\":{\"color\":\"#fff359\",\"italic\":true},\"insert\":\"dwdaw\"},{\"attributes\":{\"header\":2},\"insert\":\"\\n\"},{\"insert\":\"😅❤️❤️\\n\\n\"},{\"attributes\":{\"class\":\"cut-off\"},\"insert\":{\"cut-off\":{\"type\":\"3\",\"url\":\"https://article.biliimg.com/bfs/article/db75225feabec8d8b64ee7d3c7165cd639554cbc.png\"}}},{\"insert\":\"\\n\"},{\"attributes\":{\"strike\":true,\"italic\":true},\"insert\":\"dwadw\"},{\"attributes\":{\"strike\":true,\"bold\":true},\"insert\":\"dw\"},{\"attributes\":{\"header\":1},\"insert\":\"\\n\"}]}",
    "opus_req": {
        "upload_id": "558830935_1713021023_5941",
        "opus": {
            "opus_source": 2,
            "title": "test",
            "content": {
                "paragraphs": [
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "test",
                                        "font_size": 22,
                                        "style": {
                                            "strikethrough": true,
                                            "bold": true
                                        },
                                        "color": "#60d837"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "\n",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dawhdhaw",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "ohdouhhjkkkkkkk",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true,
                                            "bold": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "kkkkkkkkkkkkkkkkkkk",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "kkkkkk",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true
                                        },
                                        "color": "#73fdea"
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "kkkkkkkkk的娃娃对我打击和我觉得家里文化的",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "交流和",
                                        "font_size": 17,
                                        "style": {
                                            "strikethrough": true,
                                            "italic": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "挖掘",
                                        "font_size": 17,
                                        "style": {
                                            "strikethrough": true,
                                            "italic": true
                                        },
                                        "color": "#60d837"
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "了觉得我很了解啊好了大家好我立即回到老家记得和我交流活动链接和网络江湖大佬",
                                        "font_size": 17,
                                        "style": {
                                            "strikethrough": true,
                                            "italic": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "教我",
                                        "font_size": 17,
                                        "style": {
                                            "italic": true
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "测试",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 6,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "d4wad444444",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        },
                        "format": {
                            "align": 2,
                            "list_format": {
                                "level": 1,
                                "order": 1
                            }
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dwdw",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        },
                        "format": {
                            "align": 1
                        }
                    },
                    {
                        "para_type": 3,
                        "format": {
                            "align": 1
                        },
                        "line": {
                            "pic": {
                                "url": "https://article.biliimg.com/bfs/article/0117cbba35e51b0bce5f8c2f6a838e8a087e8ee7.png",
                                "height": 1
                            }
                        }
                    },
                    {
                        "para_type": 4,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 4,
                                    "link": {
                                        "link_type": 16,
                                        "style": {
                                            "italic": true
                                        },
                                        "show_text": "tql",
                                        "link": "https://www.bilibili.com/video/BV1xr421b7YG?spm_id_from=333.1007.tianma.1-1-1.click"
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": " 达瓦达瓦",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "wdad",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 2,
                        "pic": {
                            "style": 1,
                            "pics": [
                                {
                                    "url": "https://article.biliimg.com/bfs/new_dyn/6e7d28ed54b3f32f8cb78f6fda21d70c558830935.jpg",
                                    "width": 3840,
                                    "height": 2160,
                                    "size": 208.7587890625
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 4,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "\n",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 3,
                        "format": {
                            "align": 1
                        },
                        "line": {
                            "pic": {
                                "url": "https://article.biliimg.com/bfs/article/02db465212d3c374a43c60fa2625cc1caeaab796.png",
                                "height": 64
                            }
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "\n",
                                        "font_size": 22,
                                        "style": {
                                            "bold": true
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "11",
                                        "font_size": 22,
                                        "style": {
                                            "bold": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dw",
                                        "font_size": 22,
                                        "style": {
                                            "bold": true
                                        },
                                        "color": "#ea0077"
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dw",
                                        "font_size": 22,
                                        "style": {
                                            "bold": true
                                        },
                                        "color": "#fff359"
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dwdaw",
                                        "font_size": 22,
                                        "style": {
                                            "italic": true,
                                            "bold": true
                                        },
                                        "color": "#fff359"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "😅❤️❤️",
                                        "font_size": 17,
                                        "style": {}
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "para_type": 3,
                        "format": {
                            "align": 1
                        },
                        "line": {
                            "pic": {
                                "url": "https://article.biliimg.com/bfs/article/db75225feabec8d8b64ee7d3c7165cd639554cbc.png",
                                "height": 16
                            }
                        }
                    },
                    {
                        "para_type": 1,
                        "text": {
                            "nodes": [
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "\n",
                                        "font_size": 24,
                                        "style": {
                                            "bold": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dwadw",
                                        "font_size": 24,
                                        "style": {
                                            "strikethrough": true,
                                            "italic": true,
                                            "bold": true
                                        }
                                    }
                                },
                                {
                                    "node_type": 1,
                                    "word": {
                                        "words": "dw",
                                        "font_size": 24,
                                        "style": {
                                            "strikethrough": true,
                                            "bold": true
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "article": {
                "category_id": 15,
                "list_id": 0,
                "originality": 0,
                "reproduced": 0,
                "biz_tags": []
            },
            "pub_info": {}
        },
        "scene": 12,
        "meta": {
            "app_meta": {
                "from": "create.article.web",
                "mobi_app": "web"
            }
        },
        "option": {}
    },
    "draft_id_str": "305716"
}

以及不选择旧版编辑器就没法用以下功能,还有调字体

image

但这些功能必要性有待考究,坑太大,我建议暂时不考虑

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

很明显得做俩 dump...有待分析,zzz

@adk23333
Copy link

很难受的是,不提交就么有 paragraphs 字段,这段得分析一会,多尝试提交几次...

我主要测的是app这边,我看看有没有

@adk23333
Copy link

adk23333 commented Apr 13, 2024

但这些功能必要性有待考究,坑太大,我建议暂时不考虑

是的,先做普通文字与图片,或许会加个投票,别的看上去也没啥人用。

文字的格式也可以先放一放

说实话,破站也觉得有如下这些功能就差不多了
Screenshot_2024-04-14-00-16-09-154_tv.danmaku.bili.jpg

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 13, 2024

很难受的是,不提交就么有 paragraphs 字段,这段得分析一会,多尝试提交几次...

我主要测的是app这边,我看看有没有

现在这还没做 APP 鉴权,APP 接口不太好搞

@adk23333
Copy link

这二维码后续得修一下,pycharm里面会显示不全

IMG_20240414_162059.jpg

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 14, 2024

这二维码后续得修一下,pycharm里面会显示不全

IMG_20240414_162059.jpg

这个没辙吧...自己把输出行数搞大

@adk23333
Copy link

调了,解决,行高0.8刚刚好

@adk23333
Copy link

adk23333 commented Apr 14, 2024

很难受的是,不提交就么有 paragraphs 字段,这段得分析一会,多尝试提交几次

这个字段应该是它网页的解析器部分生成的,但,其实无所谓了。这里面并没有特别的东西,自己也能实现。我想先实现一个函数,接收*args参数,然后按顺序填入paragraph类,paragraph类则有一个nodes参数,接收*args的node类参数。
image
这个接口放dynamic如何,经过我测试,这个操作下网页端和app其实是一样的接口,参数类型也是一样的。而且网页f12下一堆红色失败连接,比app小黄鸟那边难翻(捂脸

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 14, 2024

上传接口应该和音频/视频一样都单独开个模块

@adk23333
Copy link

上传接口应该和音频/视频一样都单独开个模块

那我放opus.json了

@adk23333
Copy link

adk23333 commented Apr 14, 2024

"upload_id": "38*****89_1713085124_7191",

中间的是秒时间戳,前后两段是什么东西

前面是UID,还剩后面四位了

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 14, 2024

"upload_id": "38*****89_1713085124_7191",

中间的是秒时间戳,前后两段是什么东西

前面是UID,还剩后面四位了

我猜随机的,你试试看?

@adk23333
Copy link

发起请求的部分代码read-editor.801c8aab5cab33e714b9b0e54b38a631396e82c5.js

case 19:
    return null != e && null !== (n = e.tags) && void 0 !== n && n.length && (l.opus_req.opus.article.biz_tags = e.tags),
    null != e && e.bvid && (l.bv_id = e.bvid),
    null != e && e.timing && (u = e.timing / 1e3,
    l.opus_req.option.timer_pub_time = u,
    l.opus_req.opus.pub_info.timer_pub_time = u),
    y = "create",
    null != e && e.draftId ? l.draft_id_str = String(e.draftId) : null != e && e.dynId ? (l.dyn_id_str = e.dynId,
    y = "edit") : null != e && e.cvid && (l.cvid_str = String(e.cvid),
    y = "edit"),
    t.next = 26,
    d.a.post("/x/dynamic/feed/".concat(y, "/opus?csrf=").concat(M.a.get("bili_jct")), l, {
        headers: {
            "Content-Type": "application/json"
        },
        params: {
            gaia_source: "main_web"
        }
    });

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 21, 2024

有 upload_Id 的吗?

Repository owner deleted a comment from adk23333 Apr 21, 2024
@adk23333
Copy link

有 upload_Id 的吗?

image

用AI都没看出来,这页面是用vue编译的,实际运行的文件是旁边的1.read-editor、2.read-editor。我并不熟悉这方面的dump。

最后四位实际上用随机数字并没有问题,可以正常上传。其余的各参数的测试我放在apifox了

@adk23333
Copy link

csrfw_rid从包里面的哪里取

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 21, 2024

自动填,把 api 信息的那个 json,里面的 wbi改成 true 就行

post 请求默认带 csrf 参数

@adk23333
Copy link

adk23333 commented Apr 21, 2024

自动填,把 api 信息的那个 json,里面的 wbi改成 true 就行

了解

新建了俩个data下的json文件(meta.jsonpara_type)来放数据结构,添加三个接口(创建专栏、上传图片、保存草稿)到opus.json。

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 22, 2024

自动填,把 api 信息的那个 json,里面的 wbi改成 true 就行

了解

新建了俩个data下的json文件(meta.jsonpara_type)来放数据结构,添加三个接口(创建专栏、上传图片、保存草稿)到opus.json。

麻烦一个模块对应唯一的 json 文件,除非有大量固定的数据(如分区信息)需要归档且不再修改

数据结构指的是返回值示例,这种东西一律不保存?建议贴出来看一眼,不太好确定,麻烦给下文件

opus 泛指新图文不准确,你应该取名为 article_upload.json,遵循 video 和 audio 的命名规则

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 22, 2024

如果你能开个 pr draft 的话我可以更好的了解情况 plz =-=

@adk23333
Copy link

adk23333 commented Apr 22, 2024

如果你能开个 pr draft 的话我可以更好的了解情况 plz =-=

一点点东西而已,晚上回宿舍我直接发这里吧emmm
是请求体的json结构,基本都是枚举值

我觉得和article.json放一块更好其实,但接口path是opus,so哈哈

@adk23333
Copy link

//path: data/article_uploader_meta.json
{
  "app_meta": [
    {
      "from": "create.article.web",
      "mobi_app": "web"
    }
  ]
}
//path: data/article_uploader.json
{
  "para_type": [
    {
      "para_type": 1,
      "text": {
        "nodes": "array: node的数组"
      },
      "comment": "文字段落"
    },
    {
      "para_type": 2,
      "pic": {
        "style": 1,
        "pics": ""
      },
      "comment": "图片段落"
    },
    {
      "para_type": 3,
      "format": {
        "align": 1
      },
      "line": {
        "url": "string: 分割线图片链接",
        "height": "int: eg: 64"
      },
      "comment": "分割线段落"
    }
  ],
  "node_type": [
    {
      "node_type": 1,
      "word": {
        "words": "string: 文字小节",
        "font_size": "int: 17 正文 22 标题二",
        "style": {
          "bold": "bool: 粗体 false",
          "italic": "bool: 斜体 false"
        },
        "color": "string: #18191c #00aeec #4fd3d1 #2ac864 #ffb027 #f85a54 #ff6699"
      }
    }
  ]
}

☟这个还有一部分参数没完善,打算慢慢来

"create": {
      "url": "https://api.bilibili.com/x/dynamic/feed/create/opus",
      "method": "POST",
      "verify": true,
      "params": {
        "csrf": "string: csrf",
        "gaia_source": "main_web",
        "w_rid": "string: w_rid",
        "wts": "int: wts"
      },
      "data": {
        "raw_content": "string: 特殊格式化的opus_req.opus.content.paragraphs",
        "opus_req": {
          "upload_id": "string: {UID}_{秒时间戳}_{随机四位数字}",
          "opus": {
            "opus_source": "int: 类型",
            "title": "string: 标题",
            "content": {
              "paragraphs": "para_type[]: para_type按顺序组成的数组"
            },
            "article": {
              "category_id": "int: article_category的id",
              "list_id": 0,
              "originality": 0,
              "reproduced": 0,
              "biz_tags": "array: 标签的数组"
            },
            "pub_info": {}
          },
          "scene": 12,
          "meta": {
            "app_meta": {
              "from": "create.article.web",
              "mobi_app": "web"
            }
          },
          "option": {}
        }
      },
      "json_body": true,
      "comment": "创建专栏"
    }

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 22, 2024

//path: data/article_uploader_meta.json
{
  "app_meta": [
    {
      "from": "create.article.web",
      "mobi_app": "web"
    }
  ]
}

这种参数应该直接写死,没有给其他开发者参考的价值

应该把段落类别放进 meta.json 里面,如果非要放的话

@adk23333
Copy link

这种参数应该直接写死,没有给其他开发者参考的价值

正有此意

应该把段落类别放进 meta.json 里面,如果非要放的话

我觉得段落类别是要提出来的,本身article.py那边就做了一部分这方面的工作

@adk23333
Copy link

现在全部合成一个文件内了

// data/article_uploader.json

{
  "para_type": [
    {
      "para_type": 1,
      "text": {
        "nodes": "array: node的数组"
      },
      "comment": "文字段落"
    },
    {
      "para_type": 2,
      "pic": {
        "style": 1,
        "pics": ""
      },
      "comment": "图片段落"
    },
    {
      "para_type": 3,
      "format": {
        "align": 1
      },
      "line": {
        "url": "string: 分割线图片链接",
        "height": "int: eg: 64"
      },
      "comment": "分割线段落"
    }
  ],
  "node_type": [
    {
      "node_type": 1,
      "word": {
        "words": "string: 文本小节",
        "font_size": "int: 17 正文 22 标题二",
        "style": {
          "bold": "bool: 粗体 false",
          "italic": "bool: 斜体 false"
        },
        "color": "string: #18191c #00aeec #4fd3d1 #2ac864 #ffb027 #f85a54 #ff6699"
      }
    }
  ],
  "insert_type": [
    {
      "insert": "string: 文本",
      "comment": "正文纯文本"
    },
    {
      "attributes": {
        "header": "int: 1 标题一 2 标题二",
        "blockquote": "bool: 引用",
        "color": "string: color",
        "bold": "bool: 粗体",
        "italic": "bool: 斜体"
      },
      "insert": "string: 文本",
      "comment": "标题"
    },
    {
      "attributes": {
        "class": "normal-img"
      },
      "insert": {
        "native-image": {
          "alt": "read-normal-img",
          "url": "string: url",
          "width": 426,
          "height": 240,
          "size": "int: 图片大小KB",
          "status": "loaded"
        }
      },
      "comment": "插入的图片"
    },
    {
      "attributes": {
        "class": "cut-off"
      },
      "insert": {
        "cut-off": {
          "type": "4",
          "url": "https://i0.hdslb.com/bfs/article/4adb9255ada5b97061e610b682b8636764fe50ed.png"
        }
      },
      "comment": "分割线"
    }
  ]
}

@adk23333
Copy link

我将目前的更改推送上来了
https://github.com/adk23333/bilibili-api

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Apr 27, 2024

你要不开个 pr main...adk23333:bilibili-api:main

@adk23333
Copy link

adk23333 commented May 2, 2024

#752 (comment)

将那一堆Node类改为Paragraph类内嵌对应的Node类,比较符合这边上传的数据格式。然后保证转json和markdown结果不变即可吧

Article类大体是不变的,涉及的方法可能要有一些改动

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 3, 2024

坐等 review

@adk23333
Copy link

adk23333 commented May 3, 2024

怎么测试单个方法,我没能找到#尴尬

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 3, 2024

自己直接调用下算了...建议写完再扔进 tests 常规测试,不然好麻烦

https://github.com/Nemo2011/bilibili-api/tree/main/tests

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 3, 2024

在根目录底下开个 test.py 直接 import bilibili_api 就是了(

@adk23333
Copy link

adk23333 commented May 4, 2024

@Property装饰器可以使用吗,不可以的话,是哪些版本的py不支持

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 4, 2024

可用

@adk23333
Copy link

adk23333 commented May 4, 2024

也许fetch_content函数可以逐渐取消了,我发现了这个
image

创建专栏的方法我已经基本完成了,正在测试。我准备利用这个script标签里的数据直接转markdown和json

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 4, 2024

opus 相关请阅读 #662

理论上这里每个设计不合理的地方都是合理的,我还是建议你别碰文章解析,坑太大你吃不消...把上传做了就功德无量了

@adk23333
Copy link

adk23333 commented May 5, 2024

opus 相关请阅读 #662

抱歉,忘记这个了。

@adk23333
Copy link

adk23333 commented May 5, 2024

新版编辑器发送创建专栏的post请求前是有一个option请求的,我需要去实现模仿它吗?

@adk23333
Copy link

adk23333 commented May 6, 2024

可以进行测试了,还有部分接口参数没搞清楚,直接写死的

# 测试样例
credential = ...
p1 = TextParagraph([TextNode2("测试标题1", FontSize.Header_1)], Align.center)
ar = ArticleCreator(f"{int(time.time() * 1000)}号测试",
                    34,
                    [p1],
                    credential=credential)
ar.add_paragraph(
    TextParagraph([
        TextNode2("测试标题2:", FontSize.Header_2)
    ]),
    TextParagraph([
        TextNode2("普通文本普通文本"), TextNode2("普通文本普通文本", bold=True, italic=True, strikethrough=True)
    ]),
    TextParagraph([
        TextNode2("普通文本普通文本普通文本普通文本普通文本", color="4fd3d1"),
        LinkNode2("这是一个测试链接", "https://www.conventionalcommits.org/zh-hans/v1.0.0/")
    ], Align.center),
)
# 创建专栏
# await ar.create_opus()
# 保存草稿
await ar.draft()
image

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented May 7, 2024

新版编辑器发送创建专栏的post请求前是有一个option请求的,我需要去实现模仿它吗?

不需要,自己了解下 option HTTP方法是干嘛的...

@adk23333
Copy link

#757 (comment)

这样是否可行?

@adk23333
Copy link

终于放假有空了,继续收拾手尾

关于这个的测试你有没有什么idea

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Jul 13, 2024

终于放假有空了,继续收拾手尾

关于这个的测试你有没有什么idea

没有,基本上上传这类接口都没做测试,但可以不上传,把上传前的解析测试了

下载文章的倒是需要测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 新功能 good first issue 新的贡献者适合解决的问题 need 我要这个
Projects
None yet
Development

No branches or pull requests

2 participants