diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-09-23 12:13:08 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-09-23 12:13:08 -0500 |
| commit | 5bdd8327d4c5d8ea4960480911f713dfd56800ad (patch) | |
| tree | 42b7abcfdb7276db0dc9e849748c516fe72cb56f | |
| parent | 35ac88713320a970e3a87a26249c2a18a709f020 (diff) | |
| download | invidious-5bdd8327d4c5d8ea4960480911f713dfd56800ad.tar.gz invidious-5bdd8327d4c5d8ea4960480911f713dfd56800ad.tar.bz2 invidious-5bdd8327d4c5d8ea4960480911f713dfd56800ad.zip | |
Add better support for movies in search and watch page
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 9 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 7449a435..906d9fa5 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -234,7 +234,12 @@ def extract_items(nodeset, ucid = nil) description_html = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-description")])) description_html, description = html_to_content(description_html) - case node.xpath_node(%q(.//div[contains(@class, "yt-lockup-tile")])).not_nil!["class"] + tile = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-tile")])) + if !tile + next + end + + case tile["class"] when .includes? "yt-lockup-playlist" plid = HTTP::Params.parse(URI.parse(id).query.not_nil!)["list"] @@ -310,7 +315,6 @@ def extract_items(nodeset, ucid = nil) published = decode_date(metadata[0].content.lchop("Streamed ").lchop("Starts ")) rescue ex end - begin published ||= Time.epoch(metadata[0].xpath_node(%q(.//span)).not_nil!["data-timestamp"].to_i64) rescue ex @@ -321,7 +325,6 @@ def extract_items(nodeset, ucid = nil) view_count = metadata[0].content.rchop(" watching").delete(",").try &.to_i64? rescue ex end - begin view_count ||= metadata.try &.[1].content.delete("No views,").try &.to_i64? rescue ex diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 8d2c6988..b35e8fee 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -569,11 +569,17 @@ def fetch_video(id) published = html.xpath_node(%q(//meta[@itemprop="datePublished"])).not_nil!["content"] published = Time.parse(published, "%Y-%m-%d", Time::Location.local) - allowed_regions = html.xpath_node(%q(//meta[@itemprop="regionsAllowed"])).not_nil!["content"].split(",") - is_family_friendly = html.xpath_node(%q(//meta[@itemprop="isFamilyFriendly"])).not_nil!["content"] == "True" + allowed_regions = html.xpath_node(%q(//meta[@itemprop="regionsAllowed"])).try &.["content"].split(",") + allowed_regions ||= [] of String + is_family_friendly = html.xpath_node(%q(//meta[@itemprop="isFamilyFriendly"])).try &.["content"] == "True" + is_family_friendly ||= true genre = html.xpath_node(%q(//meta[@itemprop="genre"])).not_nil!["content"] - genre_url = html.xpath_node(%(//a[text()="#{genre}"])).not_nil!["href"] + genre_url = html.xpath_node(%(//a[text()="#{genre}"])).try &.["href"] + if genre == "Movies" + genre_url ||= "/channel/UClgRkhTL3_hImCAmdLfDE4g" + end + genre_url = "" license = html.xpath_node(%q(//h4[contains(text(),"License")]/parent::*/ul/li)) if license |
