MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / videosToShow

Function videosToShow

scripts/douyin_batchDownload.js:269–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

267 return this.videos.length;
268 },
269 videosToShow() {
270 return (
271 this.videos
272 // filter by search
273 .filter((v) => {
274 return [
275 v.desc,
276 v.author?.uid,
277 v.author?.nickname,
278 v.author?.sec_uid,
279 ].some((s) =>
280 s?.toLowerCase()?.includes(this.search.toLowerCase())
281 );
282 })
283 // sorting
284 .sort((a, b) => {
285 switch (this.sortBy) {
286 case "index":
287 return this.sortDir === "asc"
288 ? a.index - b.index
289 : b.index - a.index;
290 case "title":
291 return this.sortDir === "asc"
292 ? a.desc.localeCompare(b.desc)
293 : b.desc.localeCompare(a.desc);
294 case "author":
295 return this.sortDir === "asc"
296 ? a.author.nickname.localeCompare(b.author.nickname)
297 : b.author.nickname.localeCompare(a.author.nickname);
298 case "like":
299 return this.sortDir === "asc"
300 ? a.statistics.digg_count - b.statistics.digg_count
301 : b.statistics.digg_count - a.statistics.digg_count;
302 case "duration":
303 return this.sortDir === "asc"
304 ? a.video.duration - b.video.duration
305 : b.video.duration - a.video.duration;
306 }
307 })
308 );
309 },
310 },
311 methods: {
312 async downloadVideo() {

Callers

nothing calls this directly

Calls 2

sortMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected