Add support for setting region in Preferences.

This commit is contained in:
FireMasterK 2021-07-05 18:48:54 +05:30
parent 2877f202b7
commit b5a0ca8324
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
3 changed files with 266 additions and 2 deletions

View File

@ -56,6 +56,12 @@
<b>Buffering Goal</b>
<br />
<input class="uk-input uk-width-auto" v-model="bufferingGoal" @change="onChange($event)" type="text" />
<br />
<b>Country Selection</b>
<br />
<select class="uk-select uk-width-auto" v-model="country" @change="onChange($event)">
<option :key="country.code" v-for="country in countryMap" :value="country.code">{{ country.name }}</option>
</select>
<h2>Instances List</h2>
<table class="uk-table">
<thead>
@ -90,6 +96,7 @@
</template>
<script>
import CountryMap from "@/utils/CountryMap.js";
export default {
data() {
return {
@ -108,6 +115,8 @@ export default {
resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320],
defaultQuality: 0,
bufferingGoal: 10,
countryMap: CountryMap.COUNTRIES,
country: "US",
};
},
mounted() {
@ -136,7 +145,7 @@ export default {
});
if (localStorage) {
this.selectedInstance = localStorage.getItem("instance") || "https://pipedapi.kavin.rocks";
this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
if (localStorage.getItem("selectedSkip") !== null) {
@ -174,6 +183,7 @@ export default {
this.listen = this.getPreferenceBoolean("listen", false);
this.defaultQuality = Number(localStorage.getItem("quality"));
this.bufferingGoal = Math.max(Number(localStorage.getItem("bufferGoal")), 10);
this.country = this.getPreferenceString("region", "US");
}
},
methods: {
@ -200,6 +210,7 @@ export default {
localStorage.setItem("listen", this.listen);
localStorage.setItem("quality", this.defaultQuality);
localStorage.setItem("bufferGoal", this.bufferingGoal);
localStorage.setItem("region", this.country);
if (shouldReload) window.location.reload();
}

View File

@ -27,7 +27,7 @@ export default {
mounted() {
document.title = "Trending - Piped";
let region = this.$route.query.region;
let region = this.getPreferenceString("region", "US");
this.fetchTrending(region).then(videos => (this.videos = videos));
},

253
src/utils/CountryMap.js Normal file
View File

@ -0,0 +1,253 @@
export default {
COUNTRIES: [
{ code: "AD", name: "Andorra" },
{ code: "AE", name: "United Arab Emirates" },
{ code: "AF", name: "Afghanistan" },
{ code: "AG", name: "Antigua And Barbuda" },
{ code: "AI", name: "Anguilla" },
{ code: "AL", name: "Albania" },
{ code: "AM", name: "Armenia" },
{ code: "AO", name: "Angola" },
{ code: "AQ", name: "Antarctica" },
{ code: "AR", name: "Argentina" },
{ code: "AS", name: "American Samoa" },
{ code: "AT", name: "Austria" },
{ code: "AU", name: "Australia" },
{ code: "AW", name: "Aruba" },
{ code: "AX", name: "Aland Islands" },
{ code: "AZ", name: "Azerbaijan" },
{ code: "BA", name: "Bosnia And Herzegovina" },
{ code: "BB", name: "Barbados" },
{ code: "BD", name: "Bangladesh" },
{ code: "BE", name: "Belgium" },
{ code: "BF", name: "Burkina Faso" },
{ code: "BG", name: "Bulgaria" },
{ code: "BH", name: "Bahrain" },
{ code: "BI", name: "Burundi" },
{ code: "BJ", name: "Benin" },
{ code: "BL", name: "Saint Barthelemy" },
{ code: "BM", name: "Bermuda" },
{ code: "BN", name: "Brunei Darussalam" },
{ code: "BO", name: "Bolivia" },
{ code: "BQ", name: "BQ" },
{ code: "BR", name: "Brazil" },
{ code: "BS", name: "Bahamas" },
{ code: "BT", name: "Bhutan" },
{ code: "BV", name: "Bouvet Island" },
{ code: "BW", name: "Botswana" },
{ code: "BY", name: "Belarus" },
{ code: "BZ", name: "Belize" },
{ code: "CA", name: "Canada" },
{ code: "CC", name: "Cocos (Keeling) Islands" },
{ code: "CD", name: "Congo, Democratic Republic" },
{ code: "CF", name: "Central African Republic" },
{ code: "CG", name: "Congo" },
{ code: "CH", name: "Switzerland" },
{ code: "CI", name: "Cote D'Ivoire" },
{ code: "CK", name: "Cook Islands" },
{ code: "CL", name: "Chile" },
{ code: "CM", name: "Cameroon" },
{ code: "CN", name: "China" },
{ code: "CO", name: "Colombia" },
{ code: "CR", name: "Costa Rica" },
{ code: "CU", name: "Cuba" },
{ code: "CV", name: "Cape Verde" },
{ code: "CW", name: "CW" },
{ code: "CX", name: "Christmas Island" },
{ code: "CY", name: "Cyprus" },
{ code: "CZ", name: "Czech Republic" },
{ code: "DE", name: "Germany" },
{ code: "DJ", name: "Djibouti" },
{ code: "DK", name: "Denmark" },
{ code: "DM", name: "Dominica" },
{ code: "DO", name: "Dominican Republic" },
{ code: "DZ", name: "Algeria" },
{ code: "EC", name: "Ecuador" },
{ code: "EE", name: "Estonia" },
{ code: "EG", name: "Egypt" },
{ code: "EH", name: "Western Sahara" },
{ code: "ER", name: "Eritrea" },
{ code: "ES", name: "Spain" },
{ code: "ET", name: "Ethiopia" },
{ code: "FI", name: "Finland" },
{ code: "FJ", name: "Fiji" },
{ code: "FK", name: "Falkland Islands (Malvinas)" },
{ code: "FM", name: "Micronesia, Federated States Of" },
{ code: "FO", name: "Faroe Islands" },
{ code: "FR", name: "France" },
{ code: "GA", name: "Gabon" },
{ code: "GB", name: "United Kingdom" },
{ code: "GD", name: "Grenada" },
{ code: "GE", name: "Georgia" },
{ code: "GF", name: "French Guiana" },
{ code: "GG", name: "Guernsey" },
{ code: "GH", name: "Ghana" },
{ code: "GI", name: "Gibraltar" },
{ code: "GL", name: "Greenland" },
{ code: "GM", name: "Gambia" },
{ code: "GN", name: "Guinea" },
{ code: "GP", name: "Guadeloupe" },
{ code: "GQ", name: "Equatorial Guinea" },
{ code: "GR", name: "Greece" },
{ code: "GS", name: "South Georgia And Sandwich Isl." },
{ code: "GT", name: "Guatemala" },
{ code: "GU", name: "Guam" },
{ code: "GW", name: "Guinea-Bissau" },
{ code: "GY", name: "Guyana" },
{ code: "HK", name: "Hong Kong" },
{ code: "HM", name: "Heard Island & Mcdonald Islands" },
{ code: "HN", name: "Honduras" },
{ code: "HR", name: "Croatia" },
{ code: "HT", name: "Haiti" },
{ code: "HU", name: "Hungary" },
{ code: "ID", name: "Indonesia" },
{ code: "IE", name: "Ireland" },
{ code: "IL", name: "Israel" },
{ code: "IM", name: "Isle Of Man" },
{ code: "IN", name: "India" },
{ code: "IO", name: "British Indian Ocean Territory" },
{ code: "IQ", name: "Iraq" },
{ code: "IR", name: "Iran, Islamic Republic Of" },
{ code: "IS", name: "Iceland" },
{ code: "IT", name: "Italy" },
{ code: "JE", name: "Jersey" },
{ code: "JM", name: "Jamaica" },
{ code: "JO", name: "Jordan" },
{ code: "JP", name: "Japan" },
{ code: "KE", name: "Kenya" },
{ code: "KG", name: "Kyrgyzstan" },
{ code: "KH", name: "Cambodia" },
{ code: "KI", name: "Kiribati" },
{ code: "KM", name: "Comoros" },
{ code: "KN", name: "Saint Kitts And Nevis" },
{ code: "KP", name: "KP" },
{ code: "KR", name: "Korea" },
{ code: "KW", name: "Kuwait" },
{ code: "KY", name: "Cayman Islands" },
{ code: "KZ", name: "Kazakhstan" },
{ code: "LA", name: "Lao People's Democratic Republic" },
{ code: "LB", name: "Lebanon" },
{ code: "LC", name: "Saint Lucia" },
{ code: "LI", name: "Liechtenstein" },
{ code: "LK", name: "Sri Lanka" },
{ code: "LR", name: "Liberia" },
{ code: "LS", name: "Lesotho" },
{ code: "LT", name: "Lithuania" },
{ code: "LU", name: "Luxembourg" },
{ code: "LV", name: "Latvia" },
{ code: "LY", name: "Libyan Arab Jamahiriya" },
{ code: "MA", name: "Morocco" },
{ code: "MC", name: "Monaco" },
{ code: "MD", name: "Moldova" },
{ code: "ME", name: "Montenegro" },
{ code: "MF", name: "Saint Martin" },
{ code: "MG", name: "Madagascar" },
{ code: "MH", name: "Marshall Islands" },
{ code: "MK", name: "Macedonia" },
{ code: "ML", name: "Mali" },
{ code: "MM", name: "Myanmar" },
{ code: "MN", name: "Mongolia" },
{ code: "MO", name: "Macao" },
{ code: "MP", name: "Northern Mariana Islands" },
{ code: "MQ", name: "Martinique" },
{ code: "MR", name: "Mauritania" },
{ code: "MS", name: "Montserrat" },
{ code: "MT", name: "Malta" },
{ code: "MU", name: "Mauritius" },
{ code: "MV", name: "Maldives" },
{ code: "MW", name: "Malawi" },
{ code: "MX", name: "Mexico" },
{ code: "MY", name: "Malaysia" },
{ code: "MZ", name: "Mozambique" },
{ code: "NA", name: "Namibia" },
{ code: "NC", name: "New Caledonia" },
{ code: "NE", name: "Niger" },
{ code: "NF", name: "Norfolk Island" },
{ code: "NG", name: "Nigeria" },
{ code: "NI", name: "Nicaragua" },
{ code: "NL", name: "Netherlands" },
{ code: "NO", name: "Norway" },
{ code: "NP", name: "Nepal" },
{ code: "NR", name: "Nauru" },
{ code: "NU", name: "Niue" },
{ code: "NZ", name: "New Zealand" },
{ code: "OM", name: "Oman" },
{ code: "PA", name: "Panama" },
{ code: "PE", name: "Peru" },
{ code: "PF", name: "French Polynesia" },
{ code: "PG", name: "Papua New Guinea" },
{ code: "PH", name: "Philippines" },
{ code: "PK", name: "Pakistan" },
{ code: "PL", name: "Poland" },
{ code: "PM", name: "Saint Pierre And Miquelon" },
{ code: "PN", name: "Pitcairn" },
{ code: "PR", name: "Puerto Rico" },
{ code: "PS", name: "Palestinian Territory, Occupied" },
{ code: "PT", name: "Portugal" },
{ code: "PW", name: "Palau" },
{ code: "PY", name: "Paraguay" },
{ code: "QA", name: "Qatar" },
{ code: "RE", name: "Reunion" },
{ code: "RO", name: "Romania" },
{ code: "RS", name: "Serbia" },
{ code: "RU", name: "Russian Federation" },
{ code: "RW", name: "Rwanda" },
{ code: "SA", name: "Saudi Arabia" },
{ code: "SB", name: "Solomon Islands" },
{ code: "SC", name: "Seychelles" },
{ code: "SD", name: "Sudan" },
{ code: "SE", name: "Sweden" },
{ code: "SG", name: "Singapore" },
{ code: "SH", name: "Saint Helena" },
{ code: "SI", name: "Slovenia" },
{ code: "SJ", name: "Svalbard And Jan Mayen" },
{ code: "SK", name: "Slovakia" },
{ code: "SL", name: "Sierra Leone" },
{ code: "SM", name: "San Marino" },
{ code: "SN", name: "Senegal" },
{ code: "SO", name: "Somalia" },
{ code: "SR", name: "Suriname" },
{ code: "SS", name: "SS" },
{ code: "ST", name: "Sao Tome And Principe" },
{ code: "SV", name: "El Salvador" },
{ code: "SX", name: "SX" },
{ code: "SY", name: "Syrian Arab Republic" },
{ code: "SZ", name: "Swaziland" },
{ code: "TC", name: "Turks And Caicos Islands" },
{ code: "TD", name: "Chad" },
{ code: "TF", name: "French Southern Territories" },
{ code: "TG", name: "Togo" },
{ code: "TH", name: "Thailand" },
{ code: "TJ", name: "Tajikistan" },
{ code: "TK", name: "Tokelau" },
{ code: "TL", name: "Timor-Leste" },
{ code: "TM", name: "Turkmenistan" },
{ code: "TN", name: "Tunisia" },
{ code: "TO", name: "Tonga" },
{ code: "TR", name: "Turkey" },
{ code: "TT", name: "Trinidad And Tobago" },
{ code: "TV", name: "Tuvalu" },
{ code: "TW", name: "Taiwan" },
{ code: "TZ", name: "Tanzania" },
{ code: "UA", name: "Ukraine" },
{ code: "UG", name: "Uganda" },
{ code: "UM", name: "United States Outlying Islands" },
{ code: "US", name: "United States" },
{ code: "UY", name: "Uruguay" },
{ code: "UZ", name: "Uzbekistan" },
{ code: "VA", name: "Holy See (Vatican City State)" },
{ code: "VC", name: "Saint Vincent And Grenadines" },
{ code: "VE", name: "Venezuela" },
{ code: "VG", name: "Virgin Islands, British" },
{ code: "VI", name: "Virgin Islands, U.S." },
{ code: "VN", name: "Viet Nam" },
{ code: "VU", name: "Vanuatu" },
{ code: "WF", name: "Wallis And Futuna" },
{ code: "WS", name: "Samoa" },
{ code: "YE", name: "Yemen" },
{ code: "YT", name: "Mayotte" },
{ code: "ZA", name: "South Africa" },
{ code: "ZM", name: "Zambia" },
{ code: "ZW", name: "Zimbabwe" },
],
};