You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i use tiktok-scraper-ts as node module in vue project, i get this error. is there any solution?
ERROR Failed to compile with 1 error 14:36:10
error in ./node_modules/tiktok-scraper-ts/dist/main.js
Module parse failed: Unexpected token (1:5907)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
var D=Object.create;var v=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var U=n=>v(n,"__esModule",{value:!0}),a=(n,t)=>v(n,"name",{value:t,configurable:!0});var z=(n,t)=>{for(var e in t)v(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of F(t))!Y.call(n,o)&&(e||o!=="default")&&v(n,o,{get:()=>t[o],enumerable:!(r=P(t,o))||r.enumerable});return n},w=(n,t)=>S(U(v(n!=null?D(G(n)):{},"default",!t&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n),B=(n=>(t,e)=>n&&n.get(t)||(e=S(U({}),t,1),n&&n.set(t,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var ne={};z(ne,{Music:()=>b,TTScraper:()=>l,TikTokResult:()=>I,User:()=>f,Video:()=>p,fetchAllVideosFromUser:()=>te,fetchMusic:()=>re,fetchUser:()=>ee,fetchVideo:()=>Z,fetchVideoNoWaterMark:()=>oe,hashtag:()=>ie});var E=w(require("cheerio")),T=w(require("miniget")),x=w(require("node-fetch")),h=require("fs"),R=w(require("puppeteer")),V=w(require("http")),$=w(require("https")),N=require("process");var f=class{constructor(t,e,r,o,i,u,d,c,s,g,k,M,A,){this.id=t,this.uniqueId=e,this.nickname=r,this.avatar=o,this.signature=i,this.createdAt=u,this.verified=d,this.secretUID=c,this.bioLink=s,this.privateAccount=g,this.followers=k,this.following=M,this.hearts=A,this.videos=}};a(f,"User");var I=class{constructor(t,e,r,o,i,u,d,c,s,g){this.author=t,this.video=e,this.audio=r,this.shareCount=o,this.likesCount=i,this.commentCount=u,this.playCount=d,this.createdAt=c,this.tiktokLink=s,this.thumbnail=g}};a(I,"TikTokResult");var p=class{constructor(t,e,r,o,i,u,d,c,s,g,k,M,A,,W,q,j,J){this.id=t,this.description=e,this.createdAt=r,this.height=o,this.width=i,this.duration=u,this.resolution=d,this.shareCount=c,this.likesCount=s,this.commentCount=g,this.playCount=k,this.downloadURL=M,this.cover=A,this.dynamicCover=,this.playURL=W,this.format=q,this.author=j,this.directVideoUrl=J}};a(p,"Video");var b=class{constructor(t,e,r,o,i,u,d,c,s){this.id=t,this.title=e,this.playURL=r,this.coverLarge=o,this.coverThumb=i,this.author=u,this.duration=d,this.original=c,this.album=s}};a(b,"Music");var O=require("netscape-cookies-parser");var L=w(require("node-fetch")),K=require("tiktok-signature"),X="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.56",H="https://www.tiktok.com/api/post/item_list/?aid=1988&app_language=en&app_name=tiktok_web&battery_info=1&browser_language=en-US&browser_name=Mozilla&browser_online=true&browser_platform=Win32&browser_version=5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F107.0.0.0%20Safari%2F537.36%20Edg%2F107.0.1418.56&channel=tiktok_web&cookie_enabled=true&device_id=7165118680723998214&device_platform=web_pc&focus_state=true&from_page=user&history_len=3&is_fullscreen=false&is_page_visible=true&os=windows&priority_region=RO&referer=®ion=RO&screen_height=1440&screen_width=2560&tz_name=Europe%2FBucharest&webcast_language=en&msToken=G3C-3f8JVeDj9OTvvxfaJ_NppXWzVflwP1dOclpUOmAv4WmejB8kFwndJufXBBrXbeWNqzJgL8iF5zn33da-ZlDihRoWRjh_TDSuAgqSGAu1-4u2YlvCATAM2jl2J1dwNPf0_fk9dx1gJxQ21S0=&X-Bogus=DFSzswVYxTUANS/JS8OTqsXyYJUo&_signature=_02B4Z6wo00001CoOkNwAAIDBCa--cQz5e0wqDpRAAGoE8f",y={aid:"1988",count:35,secUid:"",cursor:"",cookie_enabled:!0,screen_width:0,screen_height:0,browser_language:"",browser_platform:"",browser_name:"",browser_version:"",browser_online:"",timezone_name:"Europe/London"};async function C(n,t){y.secUid=n,y.cursor=t;let e=new K(null,X);await e.init();let i=https://m.tiktok.com/api/post/item_list/?${new URLSearchParams(y).toString()},u=await e.sign(i),d=await e.navigator();await e.close();let{"x-tt-params":c}=u,{user_agent:s}=d,g=await Q(s,c);if(g.status!==200)throw new Error("A request to get the user's videos was not successful!");return await g.json()}a(C,"getUserVideos");async function Q(n,t){return await(0,L.default)(H,{method:"GET",headers:{"user-agent":n,"x-tt-params":t}})}a(Q,"fetchVideos");var l=class{constructor(t){this._cookiesJar=new O.CookieJar;t?this._cookies=this._cookiesJar.load(t):this._cookies=""}async requestWebsite(t,e){let r=new V.default.Agent({keepAlive:!0,maxSockets:20}),o=new $.default.Agent({keepAlive:!0,maxSockets:20}),i={agent:s=>s.protocol=="http:"?r:o,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36",Accept:"application/json, text/plain, /","Accept-Encoding":"gzip, deflate, br","Cache-Control":"no-cache",Connection:"keep-alive",Cookie:${this._cookies?this._cookiesJar.toString():""}}},d=await(await(0,x.default)(${t},e||i)).text();return E.load(d,{xmlMode:!0})}extractJSONObject(t){let e=t.split('<script id="SIGI_STATE" type="application/json">')[1].indexOf("</script>");return t.split('<script id="SIGI_STATE" type="application/json">')[1].slice(0,e)}checkJSONExisting(t){try{return!!JSON.parse(t)}catch{}}async requestWithPuppeteer(t){let e=await R.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox"]}),o=await(await e.newPage()).goto(t,{waitUntil:"domcontentloaded"});if(o==null)throw new Error("Could not load the desired Page!");let i=await o.text();return await e.close(),this.extractJSONObject(i)}handleHTMLContent(t){let e=t,r=e.split("window['SIGI_STATE']=")[1].indexOf(";window['SIGI_RETRY']=");return JSON.parse(e.split("window['SIGI_STATE']=")[1].slice(0,r))}async TryFetch(t){let e=await this.requestWebsite(t);if(this.checkJSONExisting(e("#SIGI_STATE").text()))return JSON.parse(e("#SIGI_STATE").text());{let r=await this.requestWithPuppeteer(t);return JSON.parse(r)}}async video(t,e){if(!t)throw new Error("A video URL must be provided");let r=await this.TryFetch(t),o=r.ItemList?.video?.list[0]??0;if(o==0)return console.log("Could not find the Video on Tiktok!");let i=e?await this.noWaterMark(t):r.ItemModule[o].video.playAddr.trim();return new p(o,r.ItemModule[o].desc,new Date(Number(r.ItemModule[o].createTime)1e3).toLocaleDateString(),Number(r.ItemModule[o].video.height),Number(r.ItemModule[o].video.width),Number(r.ItemModule[o].video.duration),r.ItemModule[o].video.ratio,r.ItemModule[o].stats.shareCount,r.ItemModule[o].stats.diggCount,r.ItemModule[o].stats.commentCount,r.ItemModule[o].stats.playCount,i,r.ItemModule[o].video.cover,r.ItemModule[o].video.dynamicCover,i,r.ItemModule[o].video.format,r.ItemModule[o].author,https://www.tiktok.com/@${r.ItemModule[o].author}/video/${o})}async user(t){if(!t)throw new Error("Please enter a username");let e=await this.TryFetch(https://www.tiktok.com/@${t}),r=e.UserModule.users[t];return new f(r.id,r.uniqueId,r.nickname,r.avatarLarger,r.signature.trim(),new Date(r.createTime1e3).toLocaleDateString(),r.verified,r.secUid,r?.bioLink?.link,r.privateAccount,e.UserModule.stats[t].followerCount,e.UserModule.stats[t].followingCount,e.UserModule.stats[t].heart,e.UserModule.stats[t].videoCount)}async getAllVideosFromUser(t,e){if(!t)throw new Error("You must provide a username!");let{secretUID:r}=await this.user(${t});if(!r)throw new Error("Couuld not find user UID!");let o="",i=[],u=[],d=await C(r,o);if(d?.itemList&&(u.push(d.itemList),o=d.cursor),d?.hasMore===!0)for(;;){let c=await C(r,o);if(u.push(c.itemList),o=c.cursor,c.hasMore==!1)break}for(let c of u)for(let s of c)i.push(new p(s.id,s.desc,new Date(Number(s.createTime)*1e3).toLocaleDateString(),Number(s.video?.height),Number(s.video?.width),Number(s.video?.duration),s.video?.ratio,s?.stats?.shareCount,s?.stats?.diggCount,s?.stats?.commentCount,s?.stats?.playCount,e?await this.noWaterMark(https://www.tiktok.com/@${s.author.uniqueId}/video/${s.id}):s.video?.downloadAddr.trim(),s?.video?.cover,s?.video?.dynamicCover,e?await this.noWaterMark(https://www.tiktok.com/@${s.author.uniqueId}/video/${s.id}):s.video?.downloadAddr.trim(),s?.video?.format,s.author,https://www.tiktok.com/@${s.author.uniqueId}/video/${s.id}));return i}async getMusic(t){if(!t)throw new Error("You must provide a link!");let e=await this.TryFetch(t),r=e.ItemList.video.list[0];return new b(e.ItemModule[r].music.id,e.ItemModule[r].music.title,e.ItemModule[r].music.playUrl,e.ItemModule[r].music.coverLarge,e.ItemModule[r].music.coverThumb,e.ItemModule[r].music.authorName,Number(e.ItemModule[r].music.duration),e.ItemModule[r].music.original,e.ItemModule[r].music.album)}async downloadAllVideosFromUser(t,e){if(!t)throw new Error("Please enter a username!");let r=await this.getAllVideosFromUser(t);if(!r)throw new Error("No Videos were found for this username. Either the videos are private or the user has not videos");if(!e.path){if(e.path=${__dirname}/../${t},(0,h.existsSync)(e.path)){console.log("A folder with this username exists, that is unusual!");try{(0,h.unlinkSync)(e.path)}catch(o){console.log([ERROR] Could not remove ${e.path} | Error Message: ${o.message}),(0,N.exit)(1)}}(0,h.existsSync)(e.path)||(0,h.mkdirSync)(e.path)}if(e.watermark){for(let[o,i]of r.entries()){console.log(Downloading Video: ${i.description?i.description:i.id}, [${o+1}/${r.length}]);let u=await this.noWaterMark(i.id);if(!u){console.log(Could not fetch ${i.description?i.description:i.id} with no watermark);continue}(0,T.default)(u).pipe((0,h.createWriteStream)(${e.path}/${i.id}_${i.resolution}.${i.format}))}return}for(let[o,i]of r.entries())console.log(Downloading Video: ${i.description?i.description:i.id}, [${o+1}/${r.length}]),(0,T.default)(i.downloadURL).pipe((0,h.createWriteStream)(${e.path}/${i.id}_${i.resolution}.${i.format}))}async noWaterMark(t){let e={url:t,count:"12",cursor:"0",web:"1",hd:"1"},r=await(0,x.default)("https://www.tikwm.com/api/",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(e).toString()});if(!r.ok)throw new Error("There was an Error retrieveing this video without watermark!");let o=await r.json();if(o.code===-1)throw new Error("API Limit for nowatermark, please wait 1 second and try again!");return"https://www.tikwm.com"+o.data.hdplay}async hashTag(t){if(!t)throw new Error("You must provide a tag name to complete the search!");let e=await this.TryFetch(https://www.tiktok.com/tag/${t}),{ItemList:r}=e,o=[];for(let i of r.challenge.list)o.push(new p(e.ItemModule[i].video.id,e.ItemModule[i].desc,new Date(Number(e.ItemModule[i].createTime)*1e3).toLocaleDateString(),Number(e.ItemModule[i].video.height),Number(e.ItemModule[i].video.width),Number(e.ItemModule[i].video.duration),e.ItemModule[i].video.ratio,e.ItemModule[i].stats.shareCount,e.ItemModule[i].stats.diggCount,e.ItemModule[i].stats.commentCount,e.ItemModule[i].stats.playCount,e.ItemModule[i].video.downloadAddr.trim(),e.ItemModule[i].video.cover,e.ItemModule[i].video.dynamicCover,e.ItemModule[i].video.playAddr.trim(),e.ItemModule[i].video.format,e.ItemModule[i].author));return o}};a(l,"TTScraper");async function Z(n,t){if(!n)throw new Error("You must provide a Tiktok video url!");return await new l().video(n,t)}a(Z,"fetchVideo");async function ee(n){if(!n)throw new Error("You must provide a username!");return await new l().user(n)}a(ee,"fetchUser");async function te(n,t){if(!n)throw new Error("You must provide a username!");return await new l().getAllVideosFromUser(n,t)}a(te,"fetchAllVideosFromUser");async function re(n){if(!n)throw new Error("You must provide a Tiktok video url!");return await new l().getMusic(n)}a(re,"fetchMusic");async function oe(n){if(!n)throw new Error("You must provide a Tiktok video url!");return await new l().noWaterMark(n)}a(oe,"fetchVideoNoWaterMark");async function ie(n){if(!n)throw new Error("You must provide a tiktok hashtag");return await new l().hashTag(n)}a(ie,"hashtag");module.exports=B(ne);0&&(module.exports={Music,TTScraper,TikTokResult,User,Video,fetchAllVideosFromUser,fetchMusic,fetchUser,fetchVideo,fetchVideoNoWaterMark,hashtag});
|
when i use tiktok-scraper-ts as node module in vue project, i get this error. is there any solution?
ERROR Failed to compile with 1 error 14:36:10
error in ./node_modules/tiktok-scraper-ts/dist/main.js
Module parse failed: Unexpected token (1:5907)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
@ ./src/services/TutorialDataService.ts 7:0-46 9:24-33
@ ./node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--14-2!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/components/Coba.vue?vue&type=script&lang=ts
@ ./src/components/Coba.vue?vue&type=script&lang=ts
@ ./src/components/Coba.vue
@ ./src/router.ts
@ ./src/main.ts
@ multi (webpack)-dev-server/client?http://192.168.1.8:8083&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
The text was updated successfully, but these errors were encountered: