Skip to content

Commit

Permalink
Get flags from circles-flags-svg
Browse files Browse the repository at this point in the history
  • Loading branch information
clefebvre committed Sep 20, 2023
1 parent b9656f2 commit ee620f5
Show file tree
Hide file tree
Showing 124 changed files with 304 additions and 156 deletions.
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Depends: gir1.2-xapp-1.0 (>= 2.6.0),
${misc:Depends},
libmpv2 | libmpv1,
python3-imdbpy,
python3-gi-cairo
python3-gi-cairo,
circle-flags-svg,
Recommends: yt-dlp | youtube-dl
Description: IPTV Player
Watch TV by streaming from M3U sources.
4 changes: 0 additions & 4 deletions usr/lib/hypnotix/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

TV_GROUP, MOVIES_GROUP, SERIES_GROUP = range(3)

BADGES = {}
BADGES['musik'] = "music"
BADGES['zeland'] = "newzealand"

# Used as a decorator to run things in the background
def async_function(func):
def wrapper(*args, **kwargs):
Expand Down
43 changes: 36 additions & 7 deletions usr/lib/hypnotix/hypnotix.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from imdb import IMDb
from unidecode import unidecode

from common import Manager, Provider, BADGES, MOVIES_GROUP, PROVIDERS_PATH, SERIES_GROUP, TV_GROUP,\
from common import Manager, Provider, MOVIES_GROUP, PROVIDERS_PATH, SERIES_GROUP, TV_GROUP,\
async_function, idle_function


Expand Down Expand Up @@ -70,6 +70,13 @@
"dblp": "double, planar",
}

COUNTRY_CODES = {}
with open("/usr/share/hypnotix/countries.list") as f:
for line in f:
line = line.strip()
code, name = line.split(":")
COUNTRY_CODES[name] = code

class ChannelWidget(Gtk.ListBoxRow):
""" A custom widget for displaying and holding channel data. """

Expand Down Expand Up @@ -391,18 +398,30 @@ def get_surf_based_image(self, filename, width, height):
surf = self.get_surface_for_file(filename, width, height)
return Gtk.Image.new_from_surface(surf)

def add_flag(self, code, box):
path = f"/usr/share/circle-flags-svg/{code.lower()}.svg"
if os.path.exists(path):
try:
image = self.get_surf_based_image(path, -1, 32)
box.pack_start(image, False, False, 0)
except Exception as e:
print("Could not load flag", path)
print(e)
else:
print("Couldn't find flag", path)

def add_badge(self, word, box, added_words):
if word not in added_words:
for extension in ["svg", "png"]:
badge = "/usr/share/hypnotix/pictures/badges/%s.%s" % (word, extension)
if os.path.exists(badge):
path = "/usr/share/hypnotix/pictures/badges/%s.%s" % (word, extension)
if os.path.exists(path):
try:
image = self.get_surf_based_image(badge, -1, 32)
image = self.get_surf_based_image(path, -1, 32)
box.pack_start(image, False, False, 0)
added_words.append(word)
break
except Exception as e:
print("Could not load badge", badge)
print("Could not load badge", path)
print(e)

def show_groups(self, widget, content_type):
Expand All @@ -428,10 +447,20 @@ def show_groups(self, widget, content_type):
box = Gtk.Box()
name = group.name.lower().replace("(", " ").replace(")", " ")
added_words = []

found_flag = False
for country_name in COUNTRY_CODES.keys():
if country_name.lower() in group.name.lower():
found_flag = True
self.add_flag(COUNTRY_CODES[country_name], box)
break

if not found_flag:
print(f"No flag found for: {group.name}")

for word in name.split():
self.add_badge(word, box, added_words)
if word in BADGES.keys():
self.add_badge(BADGES[word], box, added_words)

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

This file was deleted.

1 change: 0 additions & 1 deletion usr/share/hypnotix/pictures/badges/afghanistan.svg

This file was deleted.

Loading

0 comments on commit ee620f5

Please sign in to comment.