Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
takahisa.furuta authored and takahisa.furuta committed Jan 14, 2023
1 parent cbe0675 commit 116fb22
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = {
'no-bitwise': 'off',
camelcase: 'off',
'import/prefer-default-export': 'off',
"no-param-reassign": 0,
"no-continue": 'off'
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion build/core/Downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Downloader {
.on('data', chunk => {
if (chunk.length) {
buffer = Buffer.concat([buffer, chunk]);
if (this.progress && !this.bulk && barIndex && barIndex.hasOwnProperty('tick')) {
if (this.progress && !this.bulk && barIndex && Object.prototype.hasOwnProperty.call(barIndex, 'tick')) {
barIndex.tick(chunk.length, { id: item.id });
}
}
Expand Down
8 changes: 4 additions & 4 deletions build/core/TikTok.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ class TikTokScraper extends events_1.EventEmitter {
catch (_a) {
throw new Error(`Can't extract unique video id`);
}
}, err => {
}, (err) => {
if (err) {
return reject(err);
}
resolve(null);
return resolve(null);
});
});
}
Expand Down Expand Up @@ -331,7 +331,7 @@ class TikTokScraper extends events_1.EventEmitter {
if (err && err !== true) {
return reject(err);
}
resolve(null);
return resolve(null);
});
});
}
Expand Down Expand Up @@ -812,7 +812,7 @@ class TikTokScraper extends events_1.EventEmitter {
if (!response) {
throw new Error(`Can't extract video meta data`);
}
if (response.includes("__NEXT_DATA__")) {
if (response.includes('__NEXT_DATA__')) {
const rawVideoMetadata = response
.split(/<script id="__NEXT_DATA__" type="application\/json" nonce="[\w-]+" crossorigin="anonymous">/)[1]
.split(`</script>`)[0];
Expand Down
2 changes: 1 addition & 1 deletion build/helpers/Signature.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/core/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class Downloader {
.on('data', chunk => {
if (chunk.length) {
buffer = Buffer.concat([buffer, chunk as Buffer]);
if (this.progress && !this.bulk && barIndex && barIndex.hasOwnProperty('tick')) {
if (this.progress && !this.bulk && barIndex && Object.prototype.hasOwnProperty.call(barIndex, 'tick')) {
barIndex.tick(chunk.length, { id: item.id });
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/TikTok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ export class TikTokScraper extends EventEmitter {
throw new Error(`Can't extract unique video id`);
}
},
err => {
(err: any) => {
if (err) {
return reject(err);
}

resolve(null);
return resolve(null);
},
);
});
Expand Down Expand Up @@ -584,7 +584,7 @@ export class TikTokScraper extends EventEmitter {
return reject(err);
}

resolve(null);
return resolve(null);
},
);
});
Expand Down Expand Up @@ -1201,7 +1201,7 @@ export class TikTokScraper extends EventEmitter {
throw new Error(`Can't extract video meta data`);
}

if (response.includes("__NEXT_DATA__")){
if (response.includes('__NEXT_DATA__')) {
const rawVideoMetadata = response
.split(/<script id="__NEXT_DATA__" type="application\/json" nonce="[\w-]+" crossorigin="anonymous">/)[1]
.split(`</script>`)[0];
Expand All @@ -1219,7 +1219,7 @@ export class TikTokScraper extends EventEmitter {
return videoData as FeedItems;
}

throw new Error('No available parser for html page')
throw new Error('No available parser for html page');
} catch (error) {
throw new Error(`Can't extract video metadata: ${this.input}`);
}
Expand Down
4 changes: 1 addition & 3 deletions src/helpers/Signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { JSDOM, ResourceLoader } from 'jsdom';

export function sign(url: string, userAgent: string) {


const resourceLoader = new ResourceLoader({
userAgent,
});
Expand All @@ -16,7 +14,7 @@ export function sign(url: string, userAgent: string) {
contentType: 'text/html',
includeNodeLocations: true,
runScripts: 'outside-only',
resources: resourceLoader
resources: resourceLoader,
});

window.eval('console.log = () => {};');
Expand Down

1 comment on commit 116fb22

@wweevv-johndpope
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey did you get this working? seems like project is broken. I found this repo for douyin - but not working for tiktok.com - Johnserf-Seed/TikTokDownload#424

Please sign in to comment.