Commit graph

370 commits

Author SHA1 Message Date
syeopite 21e29411af
Fix extractor bugs (#2454)
* Add debug/trace logging to extract_items
* Handle invalid timestamps for livestreams extraction
* Make use of author_fallback in playlist extractor
* Don't use extract_text for video length extraction

The extract_text function attempts to extract from both the simpleText and
the runs route. This is typically what we'd want for text extraction as
it could appear in both locations. However, while this still holds true,
the thumbnailOverlayTimeStatusRenderer writes a numerical length (when
present on the video) to the simpleText route and uses runs for a
text overlay like "LIVE" or "PREMIERE".

Therefore, when a video has a text overlay instead of a numerical one,
Invidious still passes it onto decode_length_seconds, which obviously
raises since it cannot be converted into integers.

In the future, if more routes requires one text route over the other, we
should go ahead and add an argument to extract_text itself. Though for
now, this is sufficient.

* Handle unsupported "special" categories
2021-10-07 23:39:21 +02:00
Samantaz Fox adc12addfa
Add config option to display source code URL in footer (#2450) 2021-10-07 13:53:12 +02:00
syeopite 3e781b7d13
Merge pull request #2443 from iv-org/syeopite-patch-1
Use make_client when querying instance api
2021-10-02 20:00:37 +00:00
syeopite 9c44e41a4c
Merge pull request #2228 from syeopite/extract-items-overhaul
Overhaul extract_item(s) functions and add infrastructure for parsing YouTube categories
2021-10-02 20:00:16 +00:00
syeopite 73eabb6ca2
Actually fix lint 2021-10-02 08:53:58 -07:00
Samantaz Fox 5a52b4fe45
Fix lint 2021-10-02 17:41:25 +02:00
Samantaz Fox caa08a6379
Disable locales with less than 50% of strings translated 2021-10-02 17:38:06 +02:00
Samantaz Fox cd02078e26
Add Portuguese (pt) to locales
follow up to #2437
2021-10-02 17:19:28 +02:00
syeopite 77131cff91
Use make_client when querying instance api 2021-10-02 15:16:07 +00:00
syeopite 26b28cea49
Use break instead of short-circuit return 2021-10-01 05:39:23 -07:00
syeopite 23049e026f
Improve readabltiy of SearchChannel auto-gen detect 2021-09-28 08:55:02 -07:00
syeopite 9ab242ca2e
Optimize routing logic of extract_item(s) funcs 2021-09-28 08:50:23 -07:00
syeopite aa59925374
Rename get_browse_endpoint to get_browse_id 2021-09-28 08:39:00 -07:00
syeopite 43ea8fa706
Convert nil for AuthorFallback to empty strings 2021-09-28 08:25:03 -07:00
syeopite 6df85718e6
Apply suggestions from code review
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
2021-09-28 15:23:36 +00:00
syeopite 092b8a4e52
Add documentation to extractors.cr 2021-09-24 21:07:07 -07:00
syeopite e5f07dedbf
Typos and tiny styling changes 2021-09-24 21:07:07 -07:00
syeopite ca9eb0d539
Bountiful extractor changes
- Add extract_text to simplify extraction of InnerTube texts
- Add helper extractor methods to reduce repetition in parsing InnerTube
- Change [] more than 2 blocks long to use #dig or #dig?
- Remove useless ?.try blocks for items that always exists
- Add (some) documentation to VideoRendererParser
2021-09-24 21:07:07 -07:00
syeopite 142317c2be
Overhaul extractors.cr to use modules 2021-09-24 21:07:07 -07:00
syeopite 3dea670091
Switch to structs in extractors.cr for performance 2021-09-24 21:07:07 -07:00
syeopite 8435e79913
Improve documentation for extract_item(s) funcs 2021-09-24 21:07:07 -07:00
syeopite 30e85b40f9
Fix extract_videos 2021-09-24 21:07:07 -07:00
syeopite be1a43a337
Manually extract category refactor from 1b569bbc99207cae7c20aa285f42477ae361dd30
Also fixes some errors caused by cherry-picking
2021-09-24 21:07:07 -07:00
syeopite abca8f7a7c
Rename invidiousitems.cr 2021-09-24 21:07:07 -07:00
syeopite 7b60dac526
Add description_html field to Category
(cherry picked from commit aa8f15f795787113e56473f8e8fd606749a14bdd)
2021-09-24 21:07:07 -07:00
syeopite ea6434662d
Change typing of Category contents to only Array
(cherry picked from commit d3384e17f10d0baca70db7993df14100485be9da)
2021-09-24 21:07:06 -07:00
syeopite 0b7a108a59
Move continuation_token out of Category struct
(cherry picked from commit 0e96eda28f25171a0344b972af1852a4d6fc3007)
2021-09-24 21:07:06 -07:00
syeopite ae30f32c36
Unpack search items that are embedded in categories
This is a squash of a bunch of commits
cherry-picked commits

Fix category parse error on search

(cherry picked from commit cc02fed4e69f0eb5f19e017173632b3a3f20519f)

Fix category items not being extracted in search

(cherry picked from commit 2605b9c609ff217b5a6ae09d22450596dcad90fc)

Make search not include category items for now

(cherry picked from commit ca4afd59f46b595e3c339f31432cad98a5771ee1)

Change behavior of categories in search results

(cherry picked from commit cc1067561051b1c113b490e79c4a71cd346f7b3f)

Fix missing search results in extraction

(cherry picked from commit abda6840d5bfe58f845128bdd1a3f4916dd3bb84)

Fix miscount of search results

(cherry picked from commit 491e33450eb1300d0234bb33df0d0e78a027114f)
2021-09-24 21:07:06 -07:00
syeopite a50f64f6e9
Add parser for categories (shelfRenderer)
This commit adds a new parser for YT's shelfRenderers which are
typically used to denote different categories.The code for featured
channels parsing has also been moved to use the new parser but some
additional refactoring are needed there.

The ContinuationExtractor has also been improved and is now capable of
extraction continuation data that is packaged under
"appendContinuationItemsAction"

In additional this commit adds some useful helper functions to extract
the current selected tab the continuation token. This is to mainly
reduce code size and repetition.
--
This cherry-picked commit also removes the code for parsing featured
channels present on the original.

(cherry picked from commit 8000d538dbbf1eb9c78e000b1449926ba3b24da9)
2021-09-24 21:07:06 -07:00
syeopite 1323b94b7a
Rewrite extract_item and extract_items functions
This commit completely rewrites the extract_item and extract_items
function. Before this commit these two function were an unreadable
mess. The extract_item function was a lengthy if-elsif chain
while the extract_items function contained an incomprehensible
mess of .try, else and ||.

With this commit both of these functions have been pulled into a
separate file with the internal logic being moved to a few classes.

This significantly reduces the size of these two methods, enhances
readability and makes adding new extraction/parse rules much simpler.

See diff for details.

--
This cherry-picked commit also removes the code for parsing featured
channels present on the original.

(cherry picked from commit a027fbf7af1f96dc26fe5a610525ae52bcc40c28)
2021-09-24 21:06:46 -07:00
Samantaz Fox e655af251c
Try not to log search queries (#2362) 2021-09-16 09:36:22 +00:00
syeopite 5005212bec
Extract feed routes (#2269)
* Extract feed routes from invidious.cr
* Removes the deprecated route for /feed/top
* Deprecate /view_all_playlist & use /feed/playlists
* Move feed views into their own directory

* Add haltf method to halt current route context
* Change status_code + return blocks to use haltf

* Set appropriate response headers for RSS routes
2021-08-30 16:58:24 +02:00
Émilien Devos b5d2eb5c70
fetch with innertube api when video is unavailable (#2329)
+ rename some client type to better names
+ fix thirdParty hack
2021-08-16 10:41:16 -07:00
Émilien Devos 12b46bbd41
switch to innertube API for about channels (#2255) 2021-08-12 16:00:26 -07:00
TheFrenchGhosty 9b74cf3225
Typo 2021-08-03 23:57:48 +02:00
Samantaz Fox 4b46313e19
Fix crystal overrides (#2295)
* Move Crystal stdlib classes overrides to a separate file
* Document known crystal overrides
* Update crystal overrides for HTTP::Client socket
* Update shard.yml to restrict crystal versions
* Fix compilation error in Crystal 1.1.x (See
   https://github.com/crystal-lang/crystal/issues/10965
   for more details about this issue).
2021-08-03 23:44:47 +02:00
syeopite e9add69e26
Fix #resolve_url by adding ClientConfig argument
The private `_post_json` method of the YoutubeAPI requires a ClientConfig
as the third parameter. This was passed in all Youtube API methods except the
`#resolve_url` method.
2021-08-03 00:48:58 -07:00
Samantaz Fox 5b020e81ca
Youtube api improvements (#2277)
* Put youtube API functions under the YoutubeAPI namespace

* Implement the following endpoints:
  - `next`
  - `player`
  - `resolve_url`

* Allow a ClientConfig to be passed to YoutubeAPI endpoint handlers.

* Add constants for many new clients

* Fix documentation of YoutubeAPI.browse(): Comments and search
  result aren't returned by the browse() endpoint but by the next()
  and search() endpoints, respectively.

* Accept gzip compressed data, to help save on bandwidth

* Add debug/trace logging

* Other minor fixes
2021-08-03 02:58:27 +02:00
Samantaz Fox 84594b0e1e
Remove workaround for decompression of proxied files (#2286)
Was used by `proxy_file` before crystal 0.35.0.
Implemented in: f7dbf2bdd4
orphaned since: d30a972a90
2021-07-28 17:15:51 -07:00
Samantaz Fox bc937a6434
Add Korean (ko.json) to loaded locales
Required because of c83113d49b.
2021-07-26 00:15:32 +02:00
Émilien Devos 0d57a887ea
Mute unbuffered_flush IOError exception (#2235)
Related to #1416, it doesn't really fix the real error, but instead mutes the exception message.

Like explained in #1416, this "exception Error" while flushing the client data doesn't harm the client-server connection. However, this exception message continuously spams the logs and makes debugging and error finding really difficult.
2021-07-14 17:59:33 +02:00
Samantaz Fox c0e8feb66e
Add new and missing locales to i18n.cr
New locales: lt, vi
Missing: bn_BD, cs, da, eu, hu-HU, si, sk, sr, sr_Cyrl
2021-07-12 19:41:35 +02:00
Émilien Devos cf619f24a9
Remove workaround for kemalcr/kemal/issues/575 (#2230)
Full URL of the issue: https://github.com/kemalcr/kemal/issues/575
2021-07-01 16:13:06 +00:00
bopol 50267a6dd6 Use youtubei API for trending 2021-06-24 00:54:06 +02:00
Mateusz Makowski 90c907710c
Display username in header 2021-06-19 04:58:42 -07:00
syeopite cb525af0a2
Connect to api.invidious.io with https 2021-06-19 04:17:49 -07:00
syeopite 09f7e38eed
Disable automatic instance redirection by default 2021-06-19 04:17:49 -07:00
syeopite 45e57f1ad3
Refactor fetch_random_instance 2021-06-19 04:17:49 -07:00
syeopite eb911de928
Handle if inst. api is down for rand inst fetch 2021-06-19 04:17:49 -07:00
syeopite b393e31b76
Fix inst. fetching for inst w/ disabled stats/err 2021-06-19 04:17:49 -07:00