Commit Graph

81 Commits

Author SHA1 Message Date
Mike Fährmann
9dbe33b6de replace old %-formatted and .format(…) strings with f-strings (#7671)
mostly using flynt
https://github.com/ikamensh/flynt
2025-06-29 17:50:19 +02:00
Mike Fährmann
41191bb60a 'match.group(N)' -> 'match[N]' (#7671)
2.5x faster
2025-06-18 13:05:58 +02:00
Mike Fährmann
e08ec7e083 update copyright notices 2025-06-13 00:03:41 +02:00
Mike Fährmann
811b665e33 remove @staticmethod decorators
There might have been a time when calling a static method was faster
than a regular method, but that is no longer the case. According to
micro-benchmarks, it is 70% slower in CPython 3.13 and it also makes
executing the code of a class definition slower.
2025-06-12 22:50:52 +02:00
Mike Fährmann
b5c88b3d3e replace standard library 're' uses with 'util.re()' 2025-06-06 13:24:52 +02:00
Mike Fährmann
f9dd8318f1 [newgrounds] ignore '<script>' content in 'tags' (#7604) 2025-05-30 21:52:48 +02:00
Mike Fährmann
e199396872 [common] simplify 'user' extractors by using 'Dispatch' mixin 2025-05-24 18:04:53 +02:00
Mike Fährmann
57937c3b68 [newgrounds] provide 'comment_html' metadata (#7038) 2025-02-22 10:08:58 +01:00
Mike Fährmann
b069783578 [newgrounds] fix metadata extraction (#6463)
- fix 'comment' metadata
- fix 'following' extractor pattern
- use own 'type' values, since 'og:type' is no longer available
- update test results
2024-11-18 16:21:59 +01:00
Mike Fährmann
4358799833 [newgrounds] support page numbers in URLs (#6320)
https://USER.newgrounds.com/art/?page=5
https://USER.newgrounds.com/art/page/5
2024-10-14 14:25:09 +02:00
Mike Fährmann
7d0e5877ce [newgrounds] add more fallback URLs for 'art-images' files 2024-10-01 08:22:16 +02:00
Mike Fährmann
f3f27496d6 [newgrounds] support more comment embed formats (#6253) 2024-09-30 08:20:50 +02:00
Mike Fährmann
a051e1c955 directly pass exception instances as 'exc_info' logger argument 2024-09-19 14:50:08 +02:00
Mike Fährmann
c495bfe460 [newgrounds] fix warning for age-restricted posts (#6005) 2024-08-13 08:16:15 +02:00
Mike Fährmann
c6fc0281e8 [newgrounds] extend 'format' option (#5709)
- check more extensions for original formats (mp4, webm, m4v, mov, mkv)
- allow specifying which extensions and recoded formats to check
2024-06-12 20:46:45 +02:00
Mike Fährmann
329da4db5e [newgrounds] update and fix login procedure (#5109) 2024-05-23 17:06:22 +02:00
Mike Fährmann
57fc6fcf83 replace '24*3600' with '86400'
and generalize cache maxage values
2023-12-18 23:57:22 +01:00
Mike Fährmann
1f9b16a70b replace static 'sleep-request' defaults with dynamic ones 2023-12-18 22:06:26 +01:00
Mike Fährmann
7958ab1946 [newgrounds] support 'imageData' files (#4642) 2023-10-21 13:22:55 +02:00
Mike Fährmann
c4c4e4d2f4 [newgrounds] improve 'art-image' extraction (#4642)
- download files in original resolution
- replace .webp with extension of first file
2023-10-13 20:10:55 +02:00
Mike Fährmann
15f940819b [newgrounds] support 'art-image' files (#4642) 2023-10-09 11:20:10 +02:00
Mike Fährmann
3ecb512722 send Referer headers by default 2023-09-19 00:02:04 +02:00
Mike Fährmann
27ec653991 fix bug in test_init and update example URLs 2023-09-14 13:27:03 +02:00
Mike Fährmann
a453335a9f remove test results in extractor modules
and add generic example URLs
2023-09-11 16:30:55 +02:00
Mike Fährmann
a383eca7f6 decouple extractor initialization
Introduce an 'initialize()' function that does the actual init
(session, cookies, config options) and can called separately from
the constructor __init__().

This allows, for example, to adjust config access inside a Job
before most of it already happened when calling 'extractor.find()'.
2023-07-25 22:16:16 +02:00
Mike Fährmann
d97b8c2fba consistent cookie-related names
- rename every cookie variable or method to 'cookies_*'
- simplify '.session.cookies' to just '.cookies'
- more consistent 'login()' structure
2023-07-22 01:20:50 +02:00
Mike Fährmann
a16d7c59cb [newgrounds] access 'response.text' only once 2023-07-04 21:49:57 +02:00
FrostTheFox
9576652fa5 extract & pass auth token for newgrounds 2023-07-04 02:35:48 -04:00
Mike Fährmann
c698c3de44 [newgrounds] add default delay between requests (#4046) 2023-05-11 16:04:37 +02:00
Mike Fährmann
c9a7345228 [newgrounds] prevent archive ID overlap (#3681)
add an 'i' and 'a' prefix to image and audio files
(/art/view/, /audio/listen/)
since their numeric ID may conflict with movies and other media
2023-03-06 15:03:49 +01:00
Mike Fährmann
dd884b02ee replace json.loads with direct calls to JSONDecoder.decode 2023-02-09 15:22:00 +01:00
Mike Fährmann
b0cb4a1b9c replace 'text.extract()' with 'text.extr()' where possible 2022-11-05 01:14:09 +01:00
Mike Fährmann
ff532d6c3c [newgrounds] extract 'type' metadata 2022-09-24 20:29:43 +02:00
Mike Fährmann
0393e59535 [newgrounds] add 'games' extractor (#2955) 2022-09-24 12:34:37 +02:00
Mike Fährmann
c794777600 [newgrounds] prevent exception on empty results (#2727) 2022-07-03 11:44:46 +02:00
Mike Fährmann
37453a9528 [newgrounds] only login if necessary (#2715) 2022-06-29 11:46:07 +02:00
Mike Fährmann
c1768972c2 [newgrounds] update and fix pagination (#2456) 2022-04-07 15:38:41 +02:00
Mike Fährmann
a53cfc845e [newgrounds] warn about age-restricted posts (#2456) 2022-03-30 16:18:33 +02:00
Mike Fährmann
281a5b3b28 [newgrounds] fix video descriptions (#2328) 2022-03-14 08:38:20 +01:00
Mike Fährmann
d71c173150 [newgrounds] strip incomplete HTML tag from '_comment' (#2328) 2022-02-23 21:42:28 +01:00
Mike Fährmann
cf58048bd4 [newgrounds] add 'post_url' metadata field (#2328) 2022-02-23 00:00:23 +01:00
Mike Fährmann
4acc31bd9f [newgrounds] set suitabilities filter before starting a search 2022-01-11 23:50:29 +01:00
Mike Fährmann
37beb1298e [newgrounds] add 'search' extractor (closes #2161) 2022-01-06 19:32:39 +01:00
Vrihub
96fcff182c generic extractor (#735)
* Generic extractor, see issue #683

* Fix failed test_names test, no subcategory needed

* Prefix directory_fmt with "generic"

* Relax regex (would break some urls)

* Flake8 compliance

* pattern: don't require a scheme

This fixes a bug when we force the generic extractor on urls without a
scheme (that are allowed by all other extractors).

* Fix using g: and r: on urls without http(s) scheme

Almost all extractors accept urls without an initial http(s) scheme.

Many extractors also allow for generic subdomains in their "pattern"
variable; some of them implement this with the regex character class
"[^.]+" (everything but a dot).

This leads to a problem when the extractor is given a url starting
with g: or r: (to force using the generic or recursive extractor)
and without the http(s) scheme: e.g. with "r:foobar.tumblr.com"
the "r:" is wrongly considered part of the subdomain.

This commit fixes the bug, replacing the too generic "[^.]+" with the
more specific "[\w-]+" (letters, digits and "-", the only characters
allowed in domain names), which is already used by some extractors.

* Relax imageurl_pattern_ext: allow relative urls

* First round of small suggested changes

* Support image urls starting with "//"

* self.baseurl: remove trailing slash

* Relax regexp (didn't catch some image urls)

* Some fixes and cleanup

* Fix domain pattern; option to enable extractor

Fixed the domain section for "pattern", to pass "test_add" and
"test_add_module" tests.
Added the "enabled" configuration option (default False) to enable the
generic extractor. Using "g(eneric):URL" forces using the extractor.
2021-12-29 22:39:29 +01:00
Mike Fährmann
7a0da4f93f [newgrounds] add 'format' option (closes #1729) 2021-07-29 19:11:20 +02:00
Mike Fährmann
223a4e79cd [newgrounds] fix using 'category-tranfer' (#1274) 2021-07-29 15:54:04 +02:00
Mike Fährmann
36f281330a [newgrounds] fix flash file extraction (closes #1257)
… and add a 'flash' option to choose between flash and video formats.
2021-01-19 17:48:14 +01:00
Mike Fährmann
c14c5d82d6 [newgrounds] use generator for fallback URLs 2020-10-23 00:39:19 +02:00
Mike Fährmann
968d3e8465 remove '&' from URL patterns
'/?&#' -> '/?#' and '?&#' -> '?#'

According to https://www.ietf.org/rfc/rfc3986.txt, URLs are
"organized hierarchically" by using "the slash ("/"), question
mark ("?"), and number sign ("#") characters to delimit components"
2020-10-22 23:31:25 +02:00
Mike Fährmann
3f2ba629ea [newgrounds] provide fallback URLs for video downloads (#1042) 2020-10-16 01:16:12 +02:00