mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-05-07 13:17:17 +02:00
enabled quality change for yt links
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# The MIT License (MIT)
|
# The MIT License (MIT)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018-2022 Dmitriy Yefremov
|
# Copyright (c) 2018-2023 Dmitriy Yefremov
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -129,8 +129,7 @@ class YouTube:
|
|||||||
fmts = streaming_data.get("formats", None) if streaming_data else None
|
fmts = streaming_data.get("formats", None) if streaming_data else None
|
||||||
|
|
||||||
if fmts:
|
if fmts:
|
||||||
links = {Quality[i["itag"]]: i["url"] for i in filter(
|
links = {Quality[i["itag"]]: i["url"] for i in fmts if i.get("itag", -1) in Quality and "url" in i}
|
||||||
lambda i: i.get("itag", -1) in Quality, fmts) if "url" in i}
|
|
||||||
|
|
||||||
if links and title:
|
if links and title:
|
||||||
return links, title.replace("+", " ")
|
return links, title.replace("+", " ")
|
||||||
|
|||||||
@@ -252,10 +252,10 @@ class IptvDialog:
|
|||||||
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, get_yt_icon("youtube", 32))
|
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, get_yt_icon("youtube", 32))
|
||||||
else:
|
else:
|
||||||
entry.set_icon_from_stock(Gtk.EntryIconPosition.SECONDARY, None)
|
entry.set_icon_from_stock(Gtk.EntryIconPosition.SECONDARY, None)
|
||||||
self._yt_quality_box.set_visible(False)
|
|
||||||
|
|
||||||
def on_url_paste(self, entry):
|
def on_url_paste(self, entry):
|
||||||
self._inserted_url = True
|
self._inserted_url = True
|
||||||
|
self._yt_quality_box.set_visible(False)
|
||||||
|
|
||||||
def set_yt_url(self, entry, video_id):
|
def set_yt_url(self, entry, video_id):
|
||||||
try:
|
try:
|
||||||
@@ -269,7 +269,7 @@ class IptvDialog:
|
|||||||
links, title = self._yt_dl.get_yt_link(video_id, entry.get_text())
|
links, title = self._yt_dl.get_yt_link(video_id, entry.get_text())
|
||||||
yield True
|
yield True
|
||||||
except urllib.error.URLError as e:
|
except urllib.error.URLError as e:
|
||||||
self.show_info_message(get_message("Getting link error:") + (str(e)), Gtk.MessageType.ERROR)
|
self.show_info_message(f"{get_message('Getting link error:')} {e}", Gtk.MessageType.ERROR)
|
||||||
return
|
return
|
||||||
except YouTubeException as e:
|
except YouTubeException as e:
|
||||||
self.show_info_message((str(e)), Gtk.MessageType.ERROR)
|
self.show_info_message((str(e)), Gtk.MessageType.ERROR)
|
||||||
@@ -284,7 +284,7 @@ class IptvDialog:
|
|||||||
entry.set_text(links[sorted(links, key=lambda x: int(x.rstrip("p")), reverse=True)[0]])
|
entry.set_text(links[sorted(links, key=lambda x: int(x.rstrip("p")), reverse=True)[0]])
|
||||||
self._yt_links = links
|
self._yt_links = links
|
||||||
else:
|
else:
|
||||||
msg = get_message("Getting link error:") + " No link received for id: {}".format(video_id)
|
msg = f"{get_message('Getting link error:')} No link received for id: {video_id}"
|
||||||
self.show_info_message(msg, Gtk.MessageType.ERROR)
|
self.show_info_message(msg, Gtk.MessageType.ERROR)
|
||||||
finally:
|
finally:
|
||||||
entry.set_sensitive(True)
|
entry.set_sensitive(True)
|
||||||
@@ -296,10 +296,15 @@ class IptvDialog:
|
|||||||
self.update_reference_entry()
|
self.update_reference_entry()
|
||||||
|
|
||||||
def on_yt_quality_changed(self, box):
|
def on_yt_quality_changed(self, box):
|
||||||
|
if not self._yt_links:
|
||||||
|
return
|
||||||
|
|
||||||
model = box.get_model()
|
model = box.get_model()
|
||||||
active = model.get_value(box.get_active_iter(), 0)
|
active = model.get_value(box.get_active_iter(), 0)
|
||||||
if self._yt_links and active in self._yt_links:
|
if active in self._yt_links:
|
||||||
self._url_entry.set_text(self._yt_links[active])
|
self._url_entry.set_text(self._yt_links[active])
|
||||||
|
else:
|
||||||
|
self._url_entry.set_text(self._yt_links.get(max(self._yt_links, default=None), ""))
|
||||||
|
|
||||||
def save_enigma2_data(self):
|
def save_enigma2_data(self):
|
||||||
name = self._name_entry.get_text().strip()
|
name = self._name_entry.get_text().strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user