Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.1.37 #294

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.1.36",
"version": "3.1.37",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Derpibooru extends Website {
custom: 'document.body.querySelectorAll("form")[3]',
})),
_method: 'post',
'image[tag_input]': this.formatTags(tags),
'image[tag_input]': this.formatTags(tags).join(', ').trim(),
'image[image]': data.primary.file,
'image[description]': data.description,
'image[source_url]': data.options.source || data.sources[0] || '',
Expand All @@ -138,7 +138,7 @@ export class Derpibooru extends Website {
}

formatTags(tags: string[]) {
return tags.join(', ').trim();
return tags;
}

validateFileSubmission(
Expand Down
6 changes: 1 addition & 5 deletions electron-app/src/server/websites/e621/e621.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class e621 extends Website {
const form: any = {
login: accountData.username,
api_key: accountData.key,
'upload[tag_string]': this.formatTags(data.tags),
'upload[tag_string]': this.formatTags(data.tags).join(' ').trim(),
'upload[file]': data.primary.file,
'upload[rating]': this.getRating(data.rating),
'upload[description]': data.description,
Expand Down Expand Up @@ -144,10 +144,6 @@ export class e621 extends Website {
}
}

formatTags(tags: string[]) {
return super.formatTags(tags).join(' ').trim();
}

transformAccountData(data: e621AccountData) {
return {
username: data?.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class FurAffinity extends Website {
const form: any = {
key: HtmlParserUtil.getInputValue(part2.body.split('"submit-finalize"').pop(), 'key'),
title: data.title,
keywords: this.formatTags(data.tags),
keywords: this.getFormTags(data.tags),
message: data.description,
rating: this.getRating(data.rating),
create_folder_name: '',
Expand Down Expand Up @@ -346,7 +346,7 @@ export class FurAffinity extends Website {
return this.createPostResponse({ source: post.returnUrl.replace('?upload-successful', '') });
}

formatTags(tags: string[]): string {
getFormTags(tags: string[]): string {
const maxLength = 250;
tags = super.parseTags(tags).map(tag => tag.replace(/(\/|\\)/gm, '_'));
const filteredTags = tags.filter(tag => tag.length >= 3);
Expand Down
4 changes: 2 additions & 2 deletions electron-app/src/server/websites/furbooru/furbooru.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Furbooru extends Website {
custom: 'document.body.querySelectorAll("form")[3]',
})),
_method: 'post',
'image[tag_input]': this.formatTags(tags),
'image[tag_input]': this.formatTags(tags).join(', ').trim(),
'image[image]': data.primary.file,
'image[description]': data.description,
'image[source_url]': data.options.source || data.sources[0] || '',
Expand All @@ -138,7 +138,7 @@ export class Furbooru extends Website {
}

formatTags(tags: string[]) {
return tags.join(', ').trim();
return tags;
}

validateFileSubmission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Furtastic extends Website {
accountData: FurtasticAccountData,
): Promise<PostResponse> {
const form: any = {
tags: this.formatTags(data.tags),
tags: this.formatTags(data.tags).join(' ').trim(),
'file[0]': data.primary.file,
rating: this.getRating(data.rating),
description: data.description,
Expand Down Expand Up @@ -115,10 +115,6 @@ export class Furtastic extends Website {
}
}

formatTags(tags: string[]) {
return super.formatTags(tags).join(' ').trim();
}

transformAccountData(data: FurtasticAccountData) {
return {
username: data?.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class HentaiFoundry extends Website {
'Pictures[fileupload]': data.primary.file,
'Pictures[submissionPolicyAgree]': '1',
yt0: 'Create',
'Pictures[edit_tags]': this.formatTags(data.tags),
'Pictures[edit_tags]': this.formatTags(data.tags).join(', '),
'Pictures[is_scrap]': options.scraps ? '1' : '0',
'Pictures[comments_type]': options.disableComments ? '-1' : '0',
'Pictures[categoryHier]': options.category || '',
Expand Down Expand Up @@ -149,8 +149,7 @@ export class HentaiFoundry extends Website {
.substring(0, maxLength)
.split(', ')
.filter(tag => tag.length >= 3)
.join(', ')
: tagString;
: t;
}

validateFileSubmission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Inkbunny extends Website {
submission_id: upload.body.submission_id,
title: data.title,
desc: data.description,
keywords: this.formatTags(data.tags),
keywords: this.formatTags(data.tags).join(',').trim(),
};

const ratings = this.getRating(data.rating);
Expand Down Expand Up @@ -219,10 +219,6 @@ export class Inkbunny extends Website {
});
}

formatTags(tags: string[]) {
return super.formatTags(tags).join(',').trim();
}

transformAccountData(data: InkbunnyAccountData) {
return { username: data.username };
}
Expand Down
4 changes: 0 additions & 4 deletions electron-app/src/server/websites/ko-fi/ko-fi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ export class KoFi extends Website {
return this.createPostResponse({});
}

formatTags(tags: string[]) {
return super.formatTags(tags).join(',');
}

validateFileSubmission(
submission: FileSubmission,
submissionPart: SubmissionPart<KoFiFileOptions>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Manebooru extends Website {
custom: 'document.body.querySelectorAll("form")[3]',
})),
_method: 'post',
'image[tag_input]': this.formatTags(tags),
'image[tag_input]': this.formatTags(tags).join(', ').trim(),
'image[image]': data.primary.file,
'image[description]': data.description,
'image[source_url]': data.options.source || data.sources[0] || '',
Expand All @@ -138,7 +138,7 @@ export class Manebooru extends Website {
}

formatTags(tags: string[]) {
return tags.join(', ').trim();
return tags;
}

validateFileSubmission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class Newgrounds extends Website {
}
}

formatTags(tags: string[]): any {
formatTags(tags: string[]): string[] {
return super
.formatTags(tags, { spaceReplacer: '-' })
.map(tag => {
Expand Down
48 changes: 32 additions & 16 deletions electron-app/src/server/websites/patreon/patreon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export class Patreon extends Website {
if (rule.attributes.access_rule_type === 'public') {
tiers.find(t => t.value === '-1').value = rule.id;
}
if (rule.attributes.access_rule_type === 'patrons') {
tiers.push({
value: rule.id,
label: 'Patrons Only',
});
}
});

this.storeAccountInformation(profileId, GenericAccountProp.FOLDERS, tiers);
Expand Down Expand Up @@ -277,7 +283,18 @@ export class Patreon extends Website {
const link = create.data.id;

// Tags
const formattedTags = this.formatTags(data.tags);
const formattedTags = this.formatTags(data.tags)
.map(tag => {
return {
type: 'post_tag',
id: `user_defined;${tag}`,
attributes: {
value: tag,
cardinality: 1,
},
};
})
.slice(0, 50);
const relationshipTags = formattedTags.map(tag => {
return {
id: tag.id,
Expand Down Expand Up @@ -428,7 +445,18 @@ export class Patreon extends Website {
}

// Tags
const formattedTags = this.formatTags(data.tags);
const formattedTags = this.formatTags(data.tags)
.map(tag => {
return {
type: 'post_tag',
id: `user_defined;${tag}`,
attributes: {
value: tag,
cardinality: 1,
},
};
})
.slice(0, 50);
const relationshipTags = formattedTags.map(tag => {
return {
id: tag.id,
Expand Down Expand Up @@ -607,20 +635,8 @@ export class Patreon extends Website {
}
}

formatTags(tags: string[]): any {
tags = tags.filter(tag => tag.length <= 25);
return tags
.map(tag => {
return {
type: 'post_tag',
id: `user_defined;${tag}`,
attributes: {
value: tag,
cardinality: 1,
},
};
})
.slice(0, 50);
formatTags(tags: string[]): string[] {
return tags.filter(tag => tag.length <= 25);
}

validateFileSubmission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Pillowfort extends Website {
title: data.title,
content: `<p>${data.description}</p>`,
privacy: data.options.privacy,
tags: this.formatTags(data.tags),
tags: this.formatTags(data.tags).join(', '),
commit: 'Submit',
};

Expand Down Expand Up @@ -160,7 +160,7 @@ export class Pillowfort extends Website {
title: data.title,
content: `<p>${data.description}</p>`,
privacy: data.options.privacy,
tags: this.formatTags(data.tags),
tags: this.formatTags(data.tags).join(', '),
commit: 'Submit',
};

Expand Down Expand Up @@ -189,7 +189,7 @@ export class Pillowfort extends Website {
}

formatTags(tags: string[]) {
return tags.join(', ');
return tags;
}

validateFileSubmission(
Expand Down
6 changes: 3 additions & 3 deletions electron-app/src/server/websites/so-furry/so-furry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class SoFurry extends Website {
'UploadForm[binarycontent_5]': data.thumbnail || '',
'UploadForm[P_title]': data.title,
'UploadForm[description]': data.description.replace(/<\/div>(\n|\r)/g, '</div>'),
'UploadForm[formtags]': this.formatTags(data.tags),
'UploadForm[formtags]': this.formatTags(data.tags).join(', '),
'UploadForm[contentLevel]': this.getRating(data.rating),
'UploadForm[P_hidePublic]': '0',
'UploadForm[folderId]': data.options.folder || '0',
Expand Down Expand Up @@ -178,7 +178,7 @@ export class SoFurry extends Website {
'UploadForm[P_title]': data.title,
'UploadForm[textcontent]': data.description,
'UploadForm[description]': PlaintextParser.parse(data.description.split('\n')[0]),
'UploadForm[formtags]': this.formatTags(data.tags),
'UploadForm[formtags]': this.formatTags(data.tags).join(', '),
'UploadForm[contentLevel]': this.getRating(data.rating),
'UploadForm[P_hidePublic]': '0',
'UploadForm[folderId]': data.options.folder || '0',
Expand All @@ -205,7 +205,7 @@ export class SoFurry extends Website {
}

formatTags(tags: string[]) {
return tags.join(', ');
return tags;
}

validateFileSubmission(
Expand Down
6 changes: 3 additions & 3 deletions electron-app/src/server/websites/weasyl/weasyl.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class Weasyl extends Website {
title: data.title,
rating: this.convertRating(data.rating),
content: data.description,
tags: this.formatTags(data.tags),
tags: this.formatTags(data.tags).join(' '),
};

this.checkCancelled(cancellationToken);
Expand Down Expand Up @@ -162,7 +162,7 @@ export class Weasyl extends Website {
title: data.title,
rating: this.convertRating(data.rating),
content: data.description,
tags: this.formatTags(data.tags),
tags: this.formatTags(data.tags).join(' '),
submitfile: postFile,
redirect: url,
};
Expand Down Expand Up @@ -313,7 +313,7 @@ export class Weasyl extends Website {
}

formatTags(tags: string[]) {
return super.formatTags(tags).join(' ');
return super.formatTags(tags);
}

validateFileSubmission(
Expand Down
22 changes: 18 additions & 4 deletions electron-app/src/server/websites/website.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export abstract class Website {
.map(tag => tag.replace(/\s/g, options.spaceReplacer).trim());
}

formatTags(tags: string[], options?: TagParseOptions): any {
formatTags(tags: string[], options?: TagParseOptions): string[] {
return this.parseTags(tags, options);
}

Expand All @@ -139,7 +139,12 @@ export abstract class Website {
limit: number,
getLength: (text: string) => number = text => text.length,
): void {
const { includedTags, skippedTags } = this.calculateFittingTags(tags, description, limit, getLength);
const { includedTags, skippedTags } = this.calculateFittingTags(
tags,
description,
limit,
getLength,
);
const skippedCount = skippedTags.length;
if (skippedCount !== 0) {
const includedCount = includedTags.length;
Expand All @@ -161,9 +166,18 @@ export abstract class Website {
tags: string[],
description: string,
websitePart: SubmissionPartEntity<DefaultOptions>,
) : string {
): string {
const { includedTags } = this.calculateFittingTags(tags, description, this.MAX_CHARS);
return this.formatTags(includedTags).join(' ') ?? ''
const formattedTags = this.formatTags(includedTags);
if (Array.isArray(formattedTags)) {
return formattedTags.join(' ');
}

if (typeof formattedTags === 'string') {
return formattedTags;
}

return '';
}

protected calculateFittingTags(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.1.36",
"version": "3.1.37",
"description": "PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly..",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus-ui",
"version": "3.1.36",
"version": "3.1.37",
"license": "BSD-3-Clause",
"private": true,
"Author": "Michael DiCarlo",
Expand Down