ageRestrictedContent first draft
Cookie updated whenever ageRestrictedContent setting is changed or service is changed. Right now there is only a cookie for youtube, but cookies for other services could be added in the future. Problems with this approach: Even when the service is set to youtube, the downloader doesn't only request youtube urls e.g. it also sends reqeusts to i.ytimg.com, suggestqueries.google.com, and yt3.ggpht.com. The ageRestrictedContent cookie is not normally sent when sending requests to these other urls, so doing so might have unknown effects.
This commit is contained in:
parent
fc1fc6842b
commit
de4d6037d3
7 changed files with 92 additions and 11 deletions
32
app/src/main/java/org/schabi/newpipe/util/CookieUtils.java
Normal file
32
app/src/main/java/org/schabi/newpipe/util/CookieUtils.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package org.schabi.newpipe.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.schabi.newpipe.DownloaderImpl;
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CookieUtils {
|
||||
private CookieUtils() {
|
||||
}
|
||||
|
||||
public static String concatCookies(Collection<String> cookieStrings) {
|
||||
Set<String> cookieSet = new HashSet<>();
|
||||
for (String cookies : cookieStrings) {
|
||||
cookieSet.addAll(splitCookies(cookies));
|
||||
}
|
||||
return StringUtil.join(cookieSet, "; ").trim();
|
||||
}
|
||||
|
||||
public static Set<String> splitCookies(String cookies) {
|
||||
return new HashSet<>(Arrays.asList(cookies.split("; *")));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue