Display only blocked countries when queueing
This commit is contained in:
parent
2f2672ce10
commit
26f317c250
1 changed files with 34 additions and 10 deletions
|
|
@ -47,6 +47,28 @@ class YouTube:
|
|||
return videos
|
||||
|
||||
class Playlist:
|
||||
COUNTRIES = { # according to en.wikipedia.org/wiki/ISO_3166-1_alpha-2, 2018-08-17 18:12:15 UTC
|
||||
"AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU",
|
||||
"AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL",
|
||||
"BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC",
|
||||
"CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV",
|
||||
"CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG",
|
||||
"EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD",
|
||||
"GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT",
|
||||
"GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM",
|
||||
"IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH",
|
||||
"KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK",
|
||||
"LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH",
|
||||
"MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW",
|
||||
"MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR",
|
||||
"NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR",
|
||||
"PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC",
|
||||
"SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS",
|
||||
"ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL",
|
||||
"TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY",
|
||||
"UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA",
|
||||
"ZM", "ZW"
|
||||
}
|
||||
COMMON_COUNTRIES = {"DE", "FI", "FR", "GB", "IT", "JP", "NL", "PT", "US"}
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -77,12 +99,10 @@ class Playlist:
|
|||
|
||||
blocked = None
|
||||
if video.blocked is not None:
|
||||
action = "Blocked"
|
||||
blocked = set(video.blocked)
|
||||
#lines.append(f"Blocked in {', '.join(video.blocked)}.")
|
||||
if video.allowed is not None:
|
||||
action = "Only viewable"
|
||||
blocked = set(video.allowed)
|
||||
blocked = Playlist.COUNTRIES - set(video.allowed)
|
||||
#lines.append(f"Only viewable in {', '.join(video.allowed)}.")
|
||||
if blocked is not None:
|
||||
common = sorted(blocked & Playlist.COMMON_COUNTRIES)
|
||||
|
|
@ -90,14 +110,18 @@ class Playlist:
|
|||
|
||||
if common:
|
||||
if uncommon:
|
||||
text = f"{action} in {', '.join(common)} and {len(uncommon)} other countries."
|
||||
text = f"Blocked in {', '.join(common)} and {len(uncommon)} other "
|
||||
text += "country." if len(uncommon) == 1 else "countries."
|
||||
else:
|
||||
text = f"{action} in {', '.join(common)}."
|
||||
elif len(uncommon) <= 10:
|
||||
text = f"{action} in {', '.join(uncommon)}."
|
||||
else:
|
||||
text = f"{action} in {len(uncommon)} countries."
|
||||
lines.append(text)
|
||||
text = f"Blocked in {', '.join(common)}."
|
||||
lines.append(text)
|
||||
elif uncommon:
|
||||
if len(uncommon) <= 10:
|
||||
text = f"Blocked in {', '.join(uncommon)}."
|
||||
else:
|
||||
text = f"Blocked in {len(uncommon)} "
|
||||
text += "country." if len(uncommon) == 1 else "countries."
|
||||
lines.append(text)
|
||||
|
||||
return lines
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue