Merge pull request #1544 from schwukas/fix-youtube-subscription-import

Fix youtube subscription import
This commit is contained in:
TheFrenchGhosty 2020-12-07 17:03:57 +00:00 committed by GitHub
commit 68552b6d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -1492,9 +1492,10 @@ post "/data_control" do |env|
end end
end end
when "import_youtube" when "import_youtube"
subscriptions = XML.parse(body) subscriptions = JSON.parse(body)
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
channel["xmlUrl"].match(/UC[a-zA-Z0-9_-]{22}/).not_nil![0] user.subscriptions += subscriptions.as_a.compact_map do |entry|
entry["snippet"]["resourceId"]["channelId"].as_s
end end
user.subscriptions.uniq! user.subscriptions.uniq!

View File

@ -14,7 +14,7 @@
<div class="pure-control-group"> <div class="pure-control-group">
<label for="import_youtube"> <label for="import_youtube">
<a rel="noopener" target="_blank" href="https://support.google.com/youtube/answer/6224202?hl=en"> <a rel="noopener" target="_blank" href="https://github.com/iv-org/documentation/blob/master/Export-YouTube-subscriptions.md">
<%= translate(locale, "Import YouTube subscriptions") %> <%= translate(locale, "Import YouTube subscriptions") %>
</a> </a>
</label> </label>