Commit Graph

2057 Commits

Author SHA1 Message Date
evazion
8a2ae91ff2 tests: skip video file tests if ffmpeg isn't installed. 2020-06-10 18:07:54 -05:00
evazion
15799f8af7 Fix #4260: Unable to replace cdn.donmai.us images?
Bug: Replacing posts hosted on cdn.donmai.us didn't work.

Cause: Original files on cdn.donmai.us are hosted under /var/www/danbooru/original/, but replacements
were trying to store them directly under /var/www/danbooru, which failed with a permission error.
We were trying to store them in the wrong directory because we didn't respect the `original_subdir`
option when generating file paths.
2020-06-09 15:57:43 -05:00
evazion
d002701bc1 Merge pull request #4494 from nonamethanks/fix_deviantart_api_downloads
Deviantart: fix api downloads
2020-06-09 01:37:03 -05:00
evazion
484eacfd3b config: remove is_unlimited_metatag? config option. 2020-06-02 18:25:42 -05:00
evazion
9997db44d8 config: remove banned_ip_for_download? option.
* Remove `banned_ip_for_download?` config option. This isn't something that usually needs
  to be configured.
* Replace the `ipaddress` gem with `ipaddress_2`. The `ipaddress` gem has several methods
  we need (`link_local?`, etc) that are only available in master because the gem hasn't had
  an official release in several years. `ipaddress_2` is a fork that is more actively
  maintained.
2020-06-02 15:32:19 -05:00
nonamethanks
25b801619f Deviantart: fix api downloads 2020-05-31 07:01:43 +02:00
evazion
855e31ac90 nijie: fetch commentary as html instead of plaintext.
Fix regression in #4475. Fetch the commentary as html instead of
plaintext so that we don't lose links or other formatting.

Also fix it so that /jump.php redirect links are replaced with the
actual url.
2020-05-29 15:36:21 -05:00
evazion
206ac7dd9a dtext#from_html: convert basic links to <url> syntax.
Convert

    <a href="https://www.example.com">https://www.example.com</a>

to

    <https://www.example.com>

instead of

    "https://www.example.com":[https://www.example.com]
2020-05-29 15:36:21 -05:00
evazion
88d9fc4e5e sources: simplify artist finder url normalization.
Get rid of `normalized_for_artist_finder?` and `normalizable_for_artist_finder?`.
This was legacy bullshit that was originally designed to avoid API calls
when saving artist entries containing old Pixiv direct image urls that
had already been normalized, or that couldn't be normalized because they
were bad id.

Nowadays we store profile urls in artist entries instead of direct image
urls, so we don't normally need to do any API calls to normalize the
profile url. Strategies should take care to avoid triggering API calls
inside `profile_url` when possible.
2020-05-29 15:35:15 -05:00
nonamethanks
d339947647 Weibo: add source normalization 2020-05-28 01:05:11 +02:00
evazion
feeea6602c Merge pull request #4488 from nonamethanks/add_weibo_support
Add Weibo support
2020-05-27 16:53:14 -05:00
evazion
2c60a51f64 Merge pull request #4475 from nonamethanks/refactor_source_normalizing
Refactor source normalization
2020-05-27 16:52:17 -05:00
evazion
241894428a Merge pull request #4480 from BrokenEagle/fix-artstation
Fixes issues with Artstation source strategy
2020-05-27 15:37:23 -05:00
evazion
7c5510a650 media_file/flash: add license information (#4484). 2020-05-27 15:11:46 -05:00
evazion
f94c52478c media file: memoize expensive methods in subclasses. 2020-05-27 14:31:39 -05:00
nonamethanks
5c7307a1c9 Add Weibo support 2020-05-27 11:30:05 +02:00
lllusion3469
5c2ecee60f uploads: memoize dimensions of flash files
flash files can be quite big (the biggest on danbooru.donmai.us being
68.6MB atm). Reading it and applying complex transformations twice seems
unnecessary.
2020-05-25 18:58:48 +02:00
lllusion3469
b2814c1125 uploads: fix getting dimensions of flash files
MediaFile#dimensions is called twice - in #width and in #height but
it only works on the first call because the file is read to the end and
consumed the first time so when #read is called the second time it only
returns the empty string
2020-05-25 18:51:36 +02:00
evazion
c300b344de Merge pull request #4481 from BrokenEagle/fix-iqdb-image-url
Adds suport for using the image_url parameter with IQDB
2020-05-25 02:20:55 -05:00
evazion
e22e403bac Merge pull request #4478 from nonamethanks/fix_nijie_truncated_commentary
Nijie: fetch full commentary rather than truncated preview
2020-05-25 02:13:24 -05:00
evazion
20f8a26709 tests: fix rails 2.7 keyword parameter deprecation warnings. 2020-05-25 01:48:46 -05:00
evazion
3e2949d157 uploads: fix exception when uploading gifs.
Older versions of libvips don't support get("n-pages"). This is known to
fail in libvips-8.4 and known to work in libvips-8.8.
2020-05-24 12:07:17 -05:00
evazion
dc4a3bcf38 uploads: fix incorrect sample image sizing.
ref: https://danbooru.donmai.us/forum_topics/16935.

Bug: sample images were being generated to be at most 850px width *and*
850px tall. They're supposed to be at most 850px wide with unlimited height.
2020-05-23 23:29:59 -05:00
BrokenEagle
b9b1177832 Adds suport for using the image_url parameter with IQDB
This was only halfways supported, as the download module does not
have an image_url function. So for this, it just uses the url function,
which is just the original URL passed into the download function.

Additionally, it adds support to grab the largest available image,
which it does by using the file_url function of the downloads module.

- Fixes image_url parameter
- Adds file_url parameter
2020-05-24 00:58:46 +00:00
BrokenEagle
2d88569fac Fixes issues with Artstation source strategy
The reason that the download was failing was not because the 4k size
didn't exist, but because the Artstation had no way to handle image
cover URLs. This caused it to pass nil to the download function.

Additionally, there was no way to get the preview URL size, i.e. the
smallest available image for an Arstation image URL.

- Adds support for cover URLs
- Adds support for preview URL size
2020-05-24 00:38:54 +00:00
nonamethanks
116f3a67ef Nijie: fetch full commentary rather than truncated preview 2020-05-22 02:47:19 +02:00
nonamethanks
307df3b3e4 Refactor source normalization
* Move the source normalization logic out of the post model
  and into individual sources' strategies.
* Rewrite normalization tests to be handled into each source's test,
  and expand them significantly. Previously we were only testing
  a very small subset of domains and variants.
* Fix up normalization for several sites.
* Normalize fav.me urls into normal deviantart urls.
2020-05-21 22:46:51 +02:00
evazion
364343453c uploads: factor out remaining image methods to MediaFile. 2020-05-19 02:42:19 -05:00
evazion
45064853de uploads: move thumbnail generation code to MediaFile.
* Move image thumbnail generation code to MediaFile::Image.
* Move video thumbnail generation code to MediaFile::Video.
* Move ugoira->webm conversion code to MediaFile::Ugoira.

This separates thumbnail generation from the upload process so that it's
possible to generate thumbnails outside of uploads.
2020-05-18 04:19:04 -05:00
evazion
24c53172db config: remove enable_image_cropping option.
There's no need to disable this option. Supporting it adds complexity
and disabling it is untested.
2020-05-17 15:01:59 -05:00
evazion
0a12f35c47 posts/index: fix cropped thumbnails not being shown.
`show_cropped: true` wasn't being passed down to PostPresenter.preview.
2020-05-13 07:12:11 -05:00
evazion
ad02e0f62c posts/index: fix rating:s being included in page title in safe mode.
Fixes bug described in d3e4ac7c17 (commitcomment-39049351)

When dealing with searches, there are several variables we have to keep
in mind:

* Whether tag aliases should be applied.
* Whether search terms should be sorted.
* Whether the rating:s and -status:deleted metatags should be added by
  safe mode and the hide deleted posts setting.

Which of these things we need to do depends on the context:

* We want to apply aliases when actually doing the search, calculating
  the count, looking up the wiki excerpt, recording missed/popular
  searches in Reportbooru, and calculating related tags for the sidebar,
  but not when displaying the raw search as typed by the user (for
  example, in the page title or in the tag search box).
* We want to sort the search when calculating cache keys for fast_count
  or related tags, and when recording missed/popular searches, but not
  in the page title or when displaying the raw search.
* We want to add rating:s and -status:deleted when performing the
  search, calculating the count, or recording missed/popular searches,
  but not when calculating related tags for the sidebar, or when
  displaying the page title or raw search.

Here we introduce normalized_query and try to use it in contexts where
query normalization is necessary. When to use the normalized query
versus the raw unnormalized query is still subtle and prone to error.
2020-05-12 21:47:00 -05:00
evazion
cb49489f1e tests: remove SKIP_CLOUDFLARE_CHECK env variable.
This was a hack to deal with the Cloudflare check sometimes being slow
or timing out during tests. The call to https://api.cloudflare.com/client/v4/ips
could hang if there were IPv6 connectivity problems. If this happens, make
sure that IPv6 is configured properly and that `curl -v --http1.1 -6 https://api.cloudflare.com/client/v4/ips`
works.
2020-05-12 15:50:42 -05:00
evazion
bf08898837 Danbooru::Http: add default connection timeout.
* Add a three second connection timeout to all http requests. By default
  http.rb doesn't have any timeouts, so it can hang forever trying to
  connect if there are any network issues.

* Return a fake 522 error in the event of a timeout so that callers
  don't have to deal with TimeoutError exceptions, instead they can treat
  timeouts as normal 5xx errors (which most callers already handle).
2020-05-12 15:46:59 -05:00
evazion
deeb465b72 Merge pull request #4457 from lllusion3469/fix_da
Fix Deviantart
2020-05-11 16:22:48 -05:00
evazion
1578841a8a Merge pull request #4445 from nonamethanks/hentai_foundry_support
Add hentai-foundry support
2020-05-11 14:01:07 -05:00
lllusion3469
45ae8bfb6f deviantart: support non-downloadable videos 2020-05-11 19:51:04 +02:00
lllusion3469
40fa985e26 deviantart: use #at_css instead of #search
only one result needed, query is css
2020-05-11 19:51:04 +02:00
lllusion3469
0c180b521c deviantart: avoid download api call if not downloadable
because it's included in api_response which is part of /source.json
2020-05-11 19:51:04 +02:00
lllusion3469
70beb7288d rubocop: fix various issues 2020-05-11 19:51:04 +02:00
lllusion3469
0d5e31868f deviantart: fix non-downloadable flash files 2020-05-11 19:51:04 +02:00
lllusion3469
46e9f2dede deviantart: switch to Danbooru::Http
httprb doesn't seem to support a base_uri parameter so use URI.join with
a relative path instead
2020-05-11 16:11:15 +02:00
lllusion3469
2794cd254d deviantart: return nil on failure instead of ""
was also part of eba6440b8b
2020-05-11 16:11:15 +02:00
lllusion3469
413227e7de deviantart: remove #api_url
similar change in eba6440b8b

in case of #page it may get rid of the redirect if artist and title are
found
2020-05-11 16:11:15 +02:00
lllusion3469
c4a403afca deviantart: remove unreachable else
api_deviation is either #blank? (if condition) or #present?

was also part of eba6440b8b
2020-05-11 16:11:14 +02:00
lllusion3469
f4b4e12235 deviantart: use image_url as it's a single image 2020-05-11 16:10:56 +02:00
lllusion3469
769bf87a4a deviantart: don't apply /intermediary/ hack for gifs
gifs are always stored as original anyways so the /intermediary/ url
doesn't actually exist for gifs

example:
https://www.deviantart.com/heartgear/art/Silent-Night-579982816
2020-05-11 16:10:33 +02:00
lllusion3469
c2e86385a3 deviantart: don't strip metadata
was also part of eba6440b8b
2020-05-11 16:10:33 +02:00
lllusion3469
1a49ef46f9 deviantart: cache refresh token for 11 weeks
it's valid for 3 months according to this:
https://www.deviantart.com/developers/authentication#refresh

use 11 weeks instead to be safe
2020-05-11 16:10:33 +02:00
lllusion3469
f58564a71f deviantart: don't rewrite download url
it's all handled through something like
https://api-da.wixmp.com/_api/download/file?downloadToken=$TOKEN
now so those modifications aren't necessary anymore.
In fact, the one to "strip s3 query params" removes the token, breaking
the download url.
2020-05-11 16:10:32 +02:00