Fix text trimming (#89)

* Bump pillow from 9.4.0 to 9.5.0

Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.4.0 to 9.5.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.4.0...9.5.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update deploy workflow

* Fix NSFW video embeds

* Fix small embed sizes

* Update gitignore

* Fix/workarounds for failing tests

* Revert "Add info message for #74"

This reverts commit 39490a49b98ba6e56a109958dab4cb953ede4fe8.

* Fixed tweet not found error

* Fix tweet not found test

* Bump boto3 from 1.26.104 to 1.26.127

Bumps [boto3](https://github.com/boto/boto3) from 1.26.104 to 1.26.127.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](https://github.com/boto/boto3/compare/1.26.104...1.26.127)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump simple-git from 3.7.1 to 3.18.0

Bumps [simple-git](https://github.com/steveukx/git-js/tree/HEAD/simple-git) from 3.7.1 to 3.18.0.
- [Release notes](https://github.com/steveukx/git-js/releases)
- [Changelog](https://github.com/steveukx/git-js/blob/main/simple-git/CHANGELOG.md)
- [Commits](https://github.com/steveukx/git-js/commits/simple-git@3.18.0/simple-git)

---
updated-dependencies:
- dependency-name: simple-git
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump requests from 2.28.2 to 2.30.0

Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.30.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.28.2...v2.30.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix text trimming w/ old limits

* Revert "Fix text trimming w/ old limits"

This reverts commit 9d9c32b79728aece09fd1fa44625f23ee2b8cb92.

* Fix text trimming with images and text posts

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Dylan 2023-05-05 14:09:52 +01:00 committed by GitHub
parent ff6651d2ad
commit a710867f3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -3,6 +3,7 @@ failedToScanExtra = "\n\nTwitter gave me this error: "
tweetNotFound="Tweet not found."
tweetSuspended="This Tweet is from a suspended account."
videoDescLimit=220
tweetDescLimit=340
def genLikesDisplay(vnf):
@ -21,6 +22,9 @@ def genPollDisplay(poll):
def formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay):
# Trim the embed description to 248 characters, prioritizing poll and likes
limit = videoDescLimit if type=="" or type=="Video" else tweetDescLimit
output = ""
if pollDisplay==None:
pollDisplay=""
@ -40,9 +44,9 @@ def formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay):
output= body+pollDisplay+likesDisplay
else:
output= body + likesDisplay
if len(output)>tweetDescLimit:
if len(output)>limit:
# find out how many characters we need to remove
diff = len(output)-tweetDescLimit
diff = len(output)-limit
# remove the characters from body, add ellipsis
body = body[:-(diff+1)]+""
return formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay)

View File

@ -453,7 +453,7 @@ def embed(video_link, vnf, image):
image = embedVNF['images'][image]
template = 'image.html'
elif qrt['type'] == "Video" or qrt['type'] == "":
urlDesc = urllib.parse.quote(textwrap.shorten(desc, width=220, placeholder="..."))
urlDesc = urllib.parse.quote(desc)
template = 'video.html'
if vnf['type'] == "Image":
@ -466,11 +466,11 @@ def embed(video_link, vnf, image):
if vnf['isGif'] == True and config['config']['gifConvertAPI'] != "" and config['config']['gifConvertAPI'] != "none":
vnf['url'] = f"{config['config']['gifConvertAPI']}/convert.mp4?url={vnf['url']}"
appNamePost = " - GIF"
urlDesc = urllib.parse.quote(textwrap.shorten(desc, width=220, placeholder="..."))
urlDesc = urllib.parse.quote(desc)
template = 'video.html'
if vnf['type'] == "":
urlDesc = urllib.parse.quote(textwrap.shorten(desc, width=220, placeholder="..."))
urlDesc = urllib.parse.quote(desc)
template = 'video.html'
color = "#7FFFD4" # Green