Commit Graph

542 Commits

Author SHA1 Message Date
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
syeopite
2f54ec4e18 Fix locale consistency for err template redirects 2021-06-19 04:17:46 -07:00
syeopite
b9cd40fe1e Add redirect buttons to error template 2021-06-19 04:16:18 -07:00
syeopite
173cd7c15e Fix switch invidious instance btn on videos 2021-06-19 04:16:18 -07:00
syeopite
950c8f7104 Enhance fetch_random_instance func
Handle cross-inst. redirect w/ broken health stats

Add check for instance version in cross-redirect
2021-06-19 04:16:18 -07:00
syeopite
b63bebb519 Allow automatic instance redirect to be turned off
Instead the "switch invidious instance" link would bring users to
redirect.invidious.io
2021-06-19 04:16:18 -07:00
syeopite
311e7684b2 Add instance redirect on empty/broken search 2021-06-19 04:16:18 -07:00
syeopite
5b47438b71 Add helper function to fetch random instance 2021-06-19 04:16:17 -07:00
TheFrenchGhosty
c33ee83d87 Merge pull request #2124 from raycheung/master
Fix storyboard when proxied with an external port
2021-06-19 07:45:33 +00:00
TheFrenchGhosty
f88e5f09b4 Merge pull request #2152 from syeopite/hooks-and-scripts
Add scripts to ease development
2021-06-19 07:38:33 +00:00
Samantaz Fox
a2f5342a83 Multiple search fixes
* Remove percent-encoding of the search query when calling youtube API, as it
  breaks UTF-8
* Empty search redirects to /search, not /
* Show the fullscreen search "home page" (from #1977) at /search
* Allow 'region=' parameter to be passed to /search
* Other minor fixes
2021-06-13 21:52:36 +02:00
syeopite
6c9dd8deb6 Change internal i18n key of sv-SE from sv to sv-SE 2021-06-13 06:23:18 -07:00
syeopite
065c104f27 Upgrade to crystal 1.0.0 2021-06-08 13:10:58 -07:00
Ray Cheung
ca5d5668d9 Fix storyboard when proxied with an external port
Say if it's `http://host:port` internally and proxied to
`https://domain:external_port`, the storyboard URL was rendered as
`https://domain:port`.
2021-05-29 11:43:39 +08:00
Samantaz Fox
b7fe212a18 Fix youtube API function's documentation 2021-05-24 15:25:00 +02:00
Samantaz Fox
cbabf0ae7e Craft the "context" data in a dedicated function
As the amount of API endpoint function grow, this will
prevent ugly code copy/pasta
2021-05-24 13:44:49 +02:00
Samantaz Fox
344ccf3b03 Use '/youtubei/v1/browse' endpoint for playlists 2021-05-24 13:19:28 +02:00
Samantaz Fox
26a7e1b049 Use '/youtubei/v1/search' endpoint for search queries 2021-05-24 13:19:28 +02:00
Samantaz Fox
43bd331e48 Multiple youtube_api.cr helper fixes
Add documentation
Bump web client version string
Add charset=UTF-8 to the 'content-type' header
Parse JSON and return it as a Hash
Handle API error messages
2021-05-24 13:19:28 +02:00
syeopite
6e6f4d5a37 Allow configurable support of interactive 360 vid 2021-05-23 09:22:37 -07:00
TheFrenchGhosty
6f899d998f Merge pull request #1968 from syeopite/iss677
Add ability to expand/collapse description.
2021-05-13 10:26:38 +02:00
TheFrenchGhosty
73da8463ca Merge pull request #1953 from syeopite/fix1673
Update regex expressions to handle unexpected '};'
2021-05-13 10:24:44 +02:00
sh4dowb
533d0a1fd4 Added "Read More" button for video descriptions 2021-05-10 00:24:11 -07:00
Samantaz Fox
cac5f20a28 Move locales definition to i18n.cr 2021-04-21 16:10:25 +02:00
TheFrenchGhosty
beea32661a Merge pull request #1975 from tenpura-shrimp/disablequic
add option to disable quic
2021-04-17 17:59:16 +00:00
TheFrenchGhosty
b9e57d0283 Merge pull request #1977 from syeopite/add996
Change empty home page to search engine like layout
2021-04-17 17:02:47 +00:00
syeopite
5c0458a887 Move navbar search bar render check to templated 2021-04-17 05:18:58 -07:00
Andrew Zhao
9a8f1a0b0a add option to disable quic 2021-04-14 12:03:31 -04:00
syeopite
428747ab69 Allow default_home config to be empty value 2021-04-04 15:20:08 -07:00