simonsmh / telegram-bili-feed-helper

Telegram bot for Bilibili links
GNU General Public License v3.0
133 stars 12 forks source link

Question about the festival id in video_parser function of the biliparse.py #10

Closed traveleryyk1999 closed 1 year ago

traveleryyk1999 commented 1 year ago

Hey, I just started to learn the code in the repository. I am really interested how to parse one link including "b23.tv/". Based on my understanding of video_parser function, this kind of link will lead to the line 694

params = {}

In the later if-else statements, the program cannot enter into line 695

if "ep_id" in params or "season_id" in params:

Then I think this part of code will be executed

  else:
      r = await client.get(
          BILI_API + "/x/web-interface/view",
          params=params,
      )
      # Video detects non-China IP
      f.infocontent = r.json()
      detail = f.infocontent.get("data")
      if not detail:
          raise ParserException("视频解析错误", r.url, f.infocontent)

But the params I mentioned before is empty, which will cause the ParserException("视频解析错误", r.url, f.infocontent) However, I know the telegram-bili-feed-helper still works with the link including "b23.tv/".

Can you explain what is wrong in my understanding of the code? Thanks! Love this bot very much.

simonsmh commented 1 year ago

https://github.com/simonsmh/telegram-bili-feed-helper/blob/e5a1e67b2f4ead556ddc53c651068c7aa13ba315/biliparser.py#L928 Actually the bot get the forwarded link first (follow 302 redirect), then get the normal link parsed. Use debugger if you want to get deeper.