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

Reduce subtitle width to better fit on gifs #31

Merged
merged 2 commits into from
Oct 5, 2024
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 src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const stringSimilarity = require('string-similarity');

const helpers = {
formatSubtitleText: (text) => {
let wrappedText = wrap(text, { width: 28, indent: '' });
let wrappedText = wrap(text, { width: 26, indent: '' });
let subtitleText = Buffer.from(wrappedText).toString('base64');
let replacedSlashText = subtitleText.replace(/\//g, '_');
let replacedPlusText = replacedSlashText.replace(/\+/g, '-');
Expand Down
6 changes: 3 additions & 3 deletions test/src/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('API', () => {
Content: text
};

let expectedText = 'VGhpcyBpcyBhIGxvbmcgcGllY2Ugb2YgdGV4dCAKdGhhdCBuZWVkcyB0byBiZSBzcGxpdCBvbiB0byAKbXVsdGlwbGUgbGluZXM_Pz8_Pz4-Pj4-';
let expectedText = 'VGhpcyBpcyBhIGxvbmcgcGllY2Ugb2YgCnRleHQgdGhhdCBuZWVkcyB0byBiZSAKc3BsaXQgb24gdG8gbXVsdGlwbGUgCmxpbmVzPz8_Pz8-Pj4-Pg==';
let expectedUrl = 'https://frinkiac.com/gif/S07E21/1/2.gif?b64lines=' + expectedText;

const axios = {
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('API', () => {
});
describe('generateGif', () => {
it('gets the appropriate gif from frinkiac', async () => {
let expectedUrl = 'https://frinkiac.com/video/S10E07/MI9Rd6R0gNkiZnr2cFb_wA8vC3k=.gif';
let expectedUrl = 'https://frinkiac.com/video/S10E07/2BgqWeuWjvumnQewtcAinhUVhXU=.gif';
let term = 'super nintendo chalmers';

let result = await api(require('axios'), config).generateGif(term);
Expand All @@ -172,7 +172,7 @@ describe('API', () => {
}).timeout(10000);

it('gets the appropriate gif from frinkiac with multiple captions', async () => {
let expectedUrl = 'https://frinkiac.com/video/S06E08/FudWxOoaKmj_5Sk8zzxbYtTqot4=.gif';
let expectedUrl = 'https://frinkiac.com/video/S06E08/CXUO_0Mn1AupcjkdvINxh3hzaSQ=.gif';
let term = "We'd ask you to come, but... You know...";

let result = await api(require('axios'), config).generateGif(term);
Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('helpers', () => {

it('adds line breaks in the text where appropriate', () => {
let text = 'This is a long piece of text that needs to be split on to multiple lines';
let expectedText = 'VGhpcyBpcyBhIGxvbmcgcGllY2Ugb2YgdGV4dCAKdGhhdCBuZWVkcyB0byBiZSBzcGxpdCBvbiB0byAKbXVsdGlwbGUgbGluZXM=';
let expectedText = 'VGhpcyBpcyBhIGxvbmcgcGllY2Ugb2YgCnRleHQgdGhhdCBuZWVkcyB0byBiZSAKc3BsaXQgb24gdG8gbXVsdGlwbGUgbGluZXM=';

let returnedText = helpers.formatSubtitleText(text);

Expand Down