フォーク元 suwako/invidious-mod
Merge branch 'master' of github.com:iv-org/invidious
このコミットが含まれているのは:
コミット
706967ed4e
|
@ -0,0 +1 @@
|
|||
custom: https://invidious.io/donate/
|
|
@ -7,9 +7,16 @@ assignees: ''
|
|||
|
||||
---
|
||||
|
||||
<!-- Please use the search function to check if the bug you found has already been reported by someone else -->
|
||||
<!-- If you want to suggest a new feature please use "Feature request" instead -->
|
||||
<!-- If you want to suggest an enhancement to an existing feature please use "Enhancement" instead -->
|
||||
<!--
|
||||
BEFORE TRYING TO REPORT A BUG:
|
||||
|
||||
* Read the FAQ!
|
||||
* Use the search function to check if there is already an issue open for your problem!
|
||||
|
||||
If you want to suggest a new feature please use "Feature request" instead
|
||||
If you want to suggest an enhancement to an existing feature please use "Enhancement" instead
|
||||
-->
|
||||
|
||||
|
||||
**Describe the bug**
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<a href="https://invidious.io/">Website</a>
|
||||
•
|
||||
<a href="https://instances.invidious.io/">Instances list</a>
|
||||
•
|
||||
<a href="https://docs.invidious.io/FAQ.md">FAQ</a>
|
||||
•
|
||||
<a href="https://docs.invidious.io/">Documentation</a>
|
||||
•
|
||||
|
|
|
@ -430,5 +430,12 @@
|
|||
"user_created_playlists": "`x` created playlists",
|
||||
"user_saved_playlists": "`x` saved playlists",
|
||||
"Video unavailable": "Video unavailable",
|
||||
"preferences_save_player_pos_label": "Save playback position: "
|
||||
"preferences_save_player_pos_label": "Save playback position: ",
|
||||
"crash_page_you_found_a_bug": "It looks like you found a bug in Invidious!",
|
||||
"crash_page_before_reporting": "Before reporting a bug, make sure that you have:",
|
||||
"crash_page_refresh": "tried to <a href=\"`x`\">refresh the page</a>",
|
||||
"crash_page_switch_instance": "tried to <a href=\"`x`\">use another instance</a>",
|
||||
"crash_page_read_the_faq": "read the <a href=\"`x`\">Frenquently Asked Questions (FAQ)</a>",
|
||||
"crash_page_search_issue": "searched for <a href=\"`x`\">existing issues on Github</a>",
|
||||
"crash_page_report_issue": "If none of the above helped, please <a href=\"`x`\">open a new issue on GitHub</a> (preferably in English) and include the following text in your message (do NOT translate that text):"
|
||||
}
|
||||
|
|
|
@ -268,18 +268,20 @@ def fetch_reddit_comments(id, sort_by = "confidence")
|
|||
headers = HTTP::Headers{"User-Agent" => "web:invidious:v#{CURRENT_VERSION} (by github.com/iv-org/invidious)"}
|
||||
|
||||
# TODO: Use something like #479 for a static list of instances to use here
|
||||
query = "(url:3D#{id}%20OR%20url:#{id})%20(site:invidio.us%20OR%20site:youtube.com%20OR%20site:youtu.be)"
|
||||
search_results = client.get("/search.json?q=#{query}", headers)
|
||||
query = URI::Params.encode({q: "(url:3D#{id} OR url:#{id}) AND (site:invidio.us OR site:youtube.com OR site:youtu.be)"})
|
||||
search_results = client.get("/search.json?#{query}", headers)
|
||||
|
||||
if search_results.status_code == 200
|
||||
search_results = RedditThing.from_json(search_results.body)
|
||||
|
||||
# For videos that have more than one thread, choose the one with the highest score
|
||||
thread = search_results.data.as(RedditListing).children.sort_by { |child| child.data.as(RedditLink).score }[-1]
|
||||
thread = thread.data.as(RedditLink)
|
||||
|
||||
result = client.get("/r/#{thread.subreddit}/comments/#{thread.id}.json?limit=100&sort=#{sort_by}", headers).body
|
||||
result = Array(RedditThing).from_json(result)
|
||||
threads = search_results.data.as(RedditListing).children
|
||||
thread = threads.max_by?(&.data.as(RedditLink).score).try(&.data.as(RedditLink))
|
||||
result = thread.try do |t|
|
||||
body = client.get("/r/#{t.subreddit}/comments/#{t.id}.json?limit=100&sort=#{sort_by}", headers).body
|
||||
Array(RedditThing).from_json(body)
|
||||
end
|
||||
result ||= [] of RedditThing
|
||||
elsif search_results.status_code == 302
|
||||
# Previously, if there was only one result then the API would redirect to that result.
|
||||
# Now, it appears it will still return a listing so this section is likely unnecessary.
|
||||
|
@ -294,7 +296,8 @@ def fetch_reddit_comments(id, sort_by = "confidence")
|
|||
|
||||
client.close
|
||||
|
||||
comments = result[1].data.as(RedditListing).children
|
||||
comments = result[1]?.try(&.data.as(RedditListing).children)
|
||||
comments ||= [] of RedditThing
|
||||
return comments, thread
|
||||
end
|
||||
|
||||
|
|
|
@ -26,22 +26,53 @@ def error_template_helper(env : HTTP::Server::Context, locale : String?, status_
|
|||
if exception.is_a?(InfoException)
|
||||
return error_template_helper(env, locale, status_code, exception.message || "")
|
||||
end
|
||||
|
||||
env.response.content_type = "text/html"
|
||||
env.response.status_code = status_code
|
||||
issue_template = %(Title: `#{exception.message} (#{exception.class})`)
|
||||
|
||||
issue_title = "#{exception.message} (#{exception.class})"
|
||||
|
||||
issue_template = %(Title: `#{issue_title}`)
|
||||
issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`)
|
||||
issue_template += %(\nRoute: `#{env.request.resource}`)
|
||||
issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`)
|
||||
# issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json)
|
||||
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
|
||||
|
||||
# URLs for the error message below
|
||||
url_faq = "https://github.com/iv-org/documentation/blob/master/FAQ.md"
|
||||
url_search_issues = "https://github.com/iv-org/invidious/issues"
|
||||
|
||||
url_switch = "https://redirect.invidious.io" + env.request.resource
|
||||
|
||||
url_new_issue = "https://github.com/iv-org/invidious/issues/new"
|
||||
url_new_issue += "?labels=bug&template=bug_report.md&title="
|
||||
url_new_issue += URI.encode_www_form("[Bug] " + issue_title)
|
||||
|
||||
error_message = <<-END_HTML
|
||||
Looks like you've found a bug in Invidious. Please open a new issue
|
||||
<a href="https://github.com/iv-org/invidious/issues">on GitHub</a>
|
||||
and include the following text in your message:
|
||||
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);">#{issue_template}</pre>
|
||||
<div class="error_message">
|
||||
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
|
||||
<br/><br/>
|
||||
|
||||
<p><b>#{translate(locale, "crash_page_before_reporting")}</b></p>
|
||||
<ul>
|
||||
<li>#{translate(locale, "crash_page_refresh", env.request.resource)}</li>
|
||||
<li>#{translate(locale, "crash_page_switch_instance", url_switch)}</li>
|
||||
<li>#{translate(locale, "crash_page_read_the_faq", url_faq)}</li>
|
||||
<li>#{translate(locale, "crash_page_search_issue", url_search_issues)}</li>
|
||||
</ul>
|
||||
|
||||
<br/>
|
||||
<p>#{translate(locale, "crash_page_report_issue", url_new_issue)}</p>
|
||||
|
||||
<!-- TODO: Add a "copy to clipboard" button -->
|
||||
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);">#{issue_template}</pre>
|
||||
</div>
|
||||
END_HTML
|
||||
|
||||
next_steps = error_redirect_helper(env, locale)
|
||||
# Don't show the usual "next steps" widget. The same options are
|
||||
# proposed above the error message, just worded differently.
|
||||
next_steps = ""
|
||||
|
||||
return templated "error"
|
||||
end
|
||||
|
|
|
@ -330,18 +330,13 @@ module Invidious::Routes::API::V1::Videos
|
|||
|
||||
begin
|
||||
comments, reddit_thread = fetch_reddit_comments(id, sort_by: sort_by)
|
||||
content_html = template_reddit_comments(comments, locale)
|
||||
|
||||
content_html = fill_links(content_html, "https", "www.reddit.com")
|
||||
content_html = replace_links(content_html)
|
||||
rescue ex
|
||||
comments = nil
|
||||
reddit_thread = nil
|
||||
content_html = ""
|
||||
end
|
||||
|
||||
if !reddit_thread || !comments
|
||||
haltf env, 404
|
||||
return error_json(404, "No reddit threads found")
|
||||
end
|
||||
|
||||
if format == "json"
|
||||
|
@ -350,6 +345,9 @@ module Invidious::Routes::API::V1::Videos
|
|||
|
||||
return reddit_thread.to_json
|
||||
else
|
||||
content_html = template_reddit_comments(comments, locale)
|
||||
content_html = fill_links(content_html, "https", "www.reddit.com")
|
||||
content_html = replace_links(content_html)
|
||||
response = {
|
||||
"title" => reddit_thread.title,
|
||||
"permalink" => reddit_thread.permalink,
|
||||
|
|
読み込み中…
新しいイシューから参照