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

Function videosToShow

scripts/tiktok_batchDownload.js:267–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

sortMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected