TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

Added support for statsV2

Open ekorian opened this issue 1 year ago • 0 comments

There is now a statsV2 object that appears to be gradually replacing the original stats object. This patch avoids crashes due to statsV2-only users, and gives priority to statsV2 over stats when both are present.

{
"stats": {"collectCount": 2787, "commentCount": 16000, "diggCount": 22600, "playCount": 1800000, "shareCount": 259}
}
{
"statsV2": {"collectCount": "2787", "commentCount": "15955", "diggCount": "22609", "playCount": "1776621", "shareCount": "259"}
}

ekorian avatar Apr 25 '24 11:04 ekorian

I'd like to understand this better. Maybe you could give a small example, with a very abbreviated version of the pandoc types (e.g. with just Str, Emph, Para, and BlockQuote).

As for the application, it's hard for me to see what you're trying to accomplish just from the types you give. I assume you're familiar with our existing Walk module?

jgm avatar May 19 '22 16:05 jgm

Yeah sure, I would be happy to make the example.

Ericson2314 avatar May 19 '22 16:05 Ericson2314

OK see https://github.com/jgm/pandoc-types/pull/99

I frequent concern when this sort of thing comes up is breaking downstream code. If that is a concern for you, I am happy to rename the variants and create a bunch of compatibility patterns

Ericson2314 avatar May 19 '22 19:05 Ericson2314

https://github.com/obsidiansystems/dombuilder-pandoc/pull/1 shows how I would change the DOM builder to use this. The "prime" functions are not recursive, and thus can be reused to render something like

data MyInline 
  = Regular (InlineF MyInline) -- fixed typo was `Inline` before
  | ReatliveLink Attr [MyInline] MyRoute Text

which would accurately represent a document with checked relative URLs.

Ericson2314 avatar May 20 '22 05:05 Ericson2314

Should that be Regular (InlineF MyInline)?

One question is how many changes would be needed to the pandoc code base if pandoc-types were to change in this way. A lot, it seems to me -- but maybe pattern synonyms could be defined that would allow current code to compile?

jgm avatar May 20 '22 15:05 jgm

Should that be Regular (InlineF MyInline)?

Yes, thanks!

One question is how many changes would be needed to the pandoc code base if pandoc-types were to change in this way. A lot, it seems to me -- but maybe pattern synonyms could be defined that would allow current code to compile?

Indeed. I wanted to wait to hear your thoughts first, but I am happy to write those pattern synonyms and then make the (far more minimal) changes in pandoc too.

Ericson2314 avatar May 20 '22 16:05 Ericson2314

Here is a report from another project that saw great utility out of structuring their AST in this way: http://newartisans.com/2018/04/win-for-recursion-schemes/ I thought it would be useful to note here.

madeline-os avatar May 20 '22 16:05 madeline-os

Thanks @madeline-os, I was completely blanking on where the existing literature was on this technique.

Ericson2314 avatar May 20 '22 16:05 Ericson2314

The one downside I can think off is that the change would make pandoc less accessible to newcomers. However, I believe that this is not as big a problem anymore. Pandoc's code base reflects more and more of the complexity that's inherent to the problems it solves, and this would be just another step in that direction.

I note that the "functorization" could potentially be used to solve jgm/pandoc#684.

tarleb avatar May 20 '22 20:05 tarleb

OK I created pattern synonyms such that that the PR should be almost breakage free. (Exception is cannot associate data constructors to type synonyms for aliases, which are used for tables.)

Ericson2314 avatar May 22 '22 04:05 Ericson2314

Have you tried compiling pandoc against the altered pandoc-types, to see where breakage might happen?

jgm avatar May 22 '22 05:05 jgm

@jgm trying that now.

Ericson2314 avatar May 22 '22 13:05 Ericson2314

https://github.com/pandoc/pandoc-lua-marshal/pull/5 https://github.com/jgm/pandoc/pull/8084 are the changes. As you can see are quite minimal and just making some imports uglier because of the GHC deficiency.

Ericson2314 avatar May 22 '22 20:05 Ericson2314

Wow, that's quite impressive. I will try to have a closer look at this before long, but it might be a couple weeks.

jgm avatar May 23 '22 17:05 jgm

Sounds good. Just let me know about any and all questions once you do :).

Ericson2314 avatar May 24 '22 14:05 Ericson2314

@jgm thanks for giving this another look and repeatedly enabling CI for me.

All 3 PRs:

  • https://github.com/jgm/pandoc-types/pull/99
  • https://github.com/pandoc/pandoc-lua-marshal/pull/5
  • https://github.com/jgm/pandoc/pull/8084

are now passing, anything more you need from me?

Ericson2314 avatar Jun 24 '22 17:06 Ericson2314

Many thanks! I was just waiting for CI to pass before taking a closer look. I'll do that next, but it may be a little while before I can find the time. Don't worry, I haven't forgotten about this.

jgm avatar Jun 24 '22 20:06 jgm

Sure, sounds good. Take the time you need and thanks for reviewing. Just want to make sure I've gotten everything done on my end, to avoid any "I am waiting on you, you wait on me" deadlock. :)

Ericson2314 avatar Jun 25 '22 19:06 Ericson2314