Skip to content

Commit

Permalink
Merge pull request #48 from mvdicarlo/develop
Browse files Browse the repository at this point in the history
v3.0.34
  • Loading branch information
mvdicarlo authored May 29, 2021
2 parents 66e7acb + d577bca commit fd74734
Show file tree
Hide file tree
Showing 11 changed files with 3,892 additions and 1,833 deletions.
4,754 changes: 3,061 additions & 1,693 deletions electron-app/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.0.33",
"version": "3.0.34",
"description": "(ClientServer) PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.",
"main": "dist/main.js",
"author": "Michael DiCarlo",
Expand Down Expand Up @@ -69,7 +69,7 @@
"request": "^2.88.0",
"rimraf": "^3.0.0",
"rxjs": "^6.6.3",
"sanitize-html": "^1.27.5",
"sanitize-html": "^2.4.0",
"set-cookie-parser": "^2.4.5",
"shortid": "^2.2.16",
"turndown": "^5.0.3",
Expand All @@ -78,7 +78,7 @@
"winston-daily-rotate-file": "^4.4.2"
},
"devDependencies": {
"@jest-runner/electron": "^2.0.3",
"@jest-runner/electron": "^3.0.1",
"@nestjs/cli": "^7.5.4",
"@nestjs/schematics": "^7.2.7",
"@nestjs/testing": "^7.6.7",
Expand Down
41 changes: 21 additions & 20 deletions electron-app/src/server/websites/furry-life/furry-life.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import * as cheerio from 'cheerio';
import {
DefaultOptions,
Expand Down Expand Up @@ -27,7 +27,6 @@ import FileSize from 'src/server/utils/filesize.util';
import FormContent from 'src/server/utils/form-content.util';
import HtmlParserUtil from 'src/server/utils/html-parser.util';
import WebsiteValidator from 'src/server/utils/website-validator.util';
import { profile } from 'winston';
import { GenericAccountProp } from '../generic/generic-account-props.enum';
import { LoginResponse } from '../interfaces/login-response.interface';
import { ScalingOptions } from '../interfaces/scaling-options.interface';
Expand All @@ -44,14 +43,15 @@ export class FurryLife extends Website {

async checkLoginStatus(data: UserAccountEntity): Promise<LoginResponse> {
const status: LoginResponse = { loggedIn: false, username: null };
const { body } = await Http.get<string>(this.BASE_URL, data._id);
const { body } = await Http.get<string>(`${this.BASE_URL}/account`, data._id);
if (!body.includes('Log in')) {
status.loggedIn = true;
const accountProfileId = body.match(/members\/(.*?)\.\d+/)[0];
status.username = accountProfileId.split(/(\.|\/)/)[2];
this.storeAccountInformation(data._id, this.PROP_ACCOUNT_ID, accountProfileId.split('/')[1]);
const $ = cheerio.load(body);
status.username = $('.avatar').siblings('.p-navgroup-linkText').text();
const accountProfileId = `${status.username}.${$('.avatar').attr('data-user-id')}`;
this.storeAccountInformation(data._id, this.PROP_ACCOUNT_ID, accountProfileId);
try {
await this.loadAlbums(data._id, accountProfileId.split('/')[1]);
await this.loadAlbums(data._id, accountProfileId);
} catch {
this.logger.error('Unable to load albums');
}
Expand All @@ -78,7 +78,7 @@ export class FurryLife extends Website {
});

const data = await Promise.all<Folder>(
albumUrls.map(async albumUrl => {
albumUrls.map(async (albumUrl) => {
const res = await Http.get<string>(`${this.BASE_URL}${albumUrl}`, profileId);
const $$ = cheerio.load(res.body);
const urlParts = albumUrl.split('/');
Expand All @@ -87,9 +87,7 @@ export class FurryLife extends Website {
return {
value: `${urlParts.pop()}-${nsfw ? 'nsfw' : 'sfw'}`,
nsfw,
label: $$('.p-title-value')
.text()
.trim(),
label: $$('.p-title-value').text().trim(),
};
}),
);
Expand All @@ -103,7 +101,7 @@ export class FurryLife extends Website {
label: 'General (SFW)',
nsfw: false,
},
...data.filter(d => !d.nsfw).sort((a, b) => a.label.localeCompare(b.label)),
...data.filter((d) => !d.nsfw).sort((a, b) => a.label.localeCompare(b.label)),
],
};

Expand All @@ -116,7 +114,7 @@ export class FurryLife extends Website {
label: 'General (NSFW)',
nsfw: true,
},
...data.filter(d => d.nsfw).sort((a, b) => a.label.localeCompare(b.label)),
...data.filter((d) => d.nsfw).sort((a, b) => a.label.localeCompare(b.label)),
],
};

Expand Down Expand Up @@ -187,7 +185,7 @@ export class FurryLife extends Website {

const isNotAlbum = options.album === this.SFW_ALBUM || options.album === this.NSFW_ALBUM;

const files = [data.primary, ...data.additional].map(f => f.file);
const files = [data.primary, ...data.additional].map((f) => f.file);

await BrowserWindowUtil.getPage(
data.part.accountId,
Expand All @@ -213,7 +211,7 @@ export class FurryLife extends Website {
this.checkCancelled(cancellationToken);
try {
const uploads = await Promise.all(
files.map(file => this.upload(data.part.accountId, token, href, file)),
files.map((file) => this.upload(data.part.accountId, token, href, file)),
);

const uploadData: any = {
Expand All @@ -231,7 +229,7 @@ export class FurryLife extends Website {
uploadData.album_id = album.split('.').pop();
}

uploads.forEach(u => {
uploads.forEach((u) => {
const mediaId = `media[${u.temp_media_id}]`;
uploadData[`${mediaId}[title]`] = data.title;
uploadData[`${mediaId}[description]`] = '';
Expand Down Expand Up @@ -294,12 +292,15 @@ export class FurryLife extends Website {
_xfResponseType: 'json',
_xfRequestUri: `/members/${this.getAccountInfo(data.part.accountId, this.PROP_ACCOUNT_ID)}`,
attachment_hash: hash,
attachment_hash_combined: hashCombined
attachment_hash_combined: hashCombined,
};

this.checkCancelled(cancellationToken);
const post = await Http.post<{ status: string; errors: any[] }>(
`${this.BASE_URL}/members/${this.getAccountInfo(data.part.accountId, this.PROP_ACCOUNT_ID)}/post`,
`${this.BASE_URL}/members/${this.getAccountInfo(
data.part.accountId,
this.PROP_ACCOUNT_ID,
)}/post`,
data.part.accountId,
{
type: 'multipart',
Expand Down Expand Up @@ -352,12 +353,12 @@ export class FurryLife extends Website {
const files = [
submission.primary,
...(submission.additional || []).filter(
f => !f.ignoredAccounts!.includes(submissionPart.accountId),
(f) => !f.ignoredAccounts!.includes(submissionPart.accountId),
),
];

const maxMB: number = 1023;
files.forEach(file => {
files.forEach((file) => {
const { type, size, name, mimetype } = file;
if (!WebsiteValidator.supportsFileType(file, this.acceptsFiles)) {
problems.push(`Does not support file format: (${name}) ${mimetype}.`);
Expand Down
14 changes: 6 additions & 8 deletions electron-app/src/server/websites/so-furry/so-furry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import _ = require('lodash');
import { FallbackInformation } from '../interfaces/fallback-information.interface';
import HtmlParser from 'src/server/description-parsing/html-node/parser';
import { HTMLFormatParser } from 'src/server/description-parsing/html/html.parser';
import BrowserWindowUtil from 'src/server/utils/browser-window.util';

@Injectable()
export class SoFurry extends Website {
Expand All @@ -47,18 +48,15 @@ export class SoFurry extends Website {

async checkLoginStatus(data: UserAccountEntity): Promise<LoginResponse> {
const status: LoginResponse = { loggedIn: false, username: null };
await BrowserWindowUtil.getPage(data._id, this.BASE_URL, true);
const res = await Http.get<string>(`${this.BASE_URL}/upload/details?contentType=1`, data._id);
if (res.body.includes('Logout')) {
status.loggedIn = true;

const $ = cheerio.load(res.body);
status.username = $('a[class=avatar]')
.attr('href')
.split('.')[0]
.split('/')
.pop();
status.username = $('a[class=avatar]').attr('href').split('.')[0].split('/').pop();
this.getFolders(data._id, $);
Http.saveSessionCookies(this.BASE_URL, data._id);
// Http.saveSessionCookies(this.BASE_URL, data._id);
}
return status;
}
Expand All @@ -68,7 +66,7 @@ export class SoFurry extends Website {
$('#UploadForm_folderId')
.children()
.toArray()
.forEach(o => {
.forEach((o) => {
folders.push({ value: $(o).attr('value'), label: $(o).text() });
});

Expand Down Expand Up @@ -228,7 +226,7 @@ export class SoFurry extends Website {
GenericAccountProp.FOLDERS,
[],
);
if (!folders.find(f => f.value === submissionPart.data.folder)) {
if (!folders.find((f) => f.value === submissionPart.data.folder)) {
warnings.push(`Folder (${submissionPart.data.folder}) not found.`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion electron-app/src/server/websites/tumblr/tumblr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class Tumblr extends Website {

let maxMB: number = 10;
if (type === FileSubmissionType.IMAGE && mimetype === 'image/gif') {
maxMB = 1;
maxMB = 10;
} else if (type === FileSubmissionType.VIDEO) {
maxMB = 100;
}
Expand Down
2 changes: 1 addition & 1 deletion electron-app/src/server/websites/website.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export abstract class Website {
readonly accountInformation: Map<string, any> = new Map();
readonly enableAdvertisement: boolean = true;
readonly refreshBeforePost: boolean = false;
readonly refreshInterval: number = 1800000;
readonly refreshInterval: number = 120_0000;
readonly usernameShortcuts: UsernameShortcut[] = [];
readonly waitBetweenPostsInterval: number = 4000;

Expand Down
Loading

0 comments on commit fd74734

Please sign in to comment.