From e8aecc1ce76cbe7bdffd47dc1373240ef446beb0 Mon Sep 17 00:00:00 2001 From: Clement Osumo Date: Tue, 20 Jun 2023 15:20:42 +0300 Subject: [PATCH] Added Android workaround --- addon.py | 14 +++++++-- addon.xml | 8 ++++- imdb.py | 30 +++++++++++++++++++ .../resource.language.en_gb/strings.po | 6 +++- resources/settings.xml | 5 ++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 imdb.py diff --git a/addon.py b/addon.py index f520368..b32acdf 100644 --- a/addon.py +++ b/addon.py @@ -4,9 +4,11 @@ import xbmcaddon import xbmcgui +from imdb import getOriginalAspectRatio + monitor = xbmc.Monitor() capture = xbmc.RenderCapture() -myplayer = xbmc.Player() +player = xbmc.Player() CaptureWidth = 48 CaptureHeight = 54 @@ -112,8 +114,16 @@ def abolishBlackBars(self): xbmcgui.Window(10000).setProperty('blackbarsnever_status', "on") # notify(xbmcgui.Window(10000).getProperty('blackbarsnever_status')) + android_workaround = (xbmcaddon.Addon().getSetting( + "automatically_execute") == 'true') + aspectratio = self.GetAspectRatioFromFrame() - aspectratio2 = int((capture.getAspectRatio() + 0.005) * 100) + + if android_workaround: + aspectratio2 = getOriginalAspectRatio( + xbmc.getInfoLabel('Player.Process(VideoTitle)')) + else: + aspectratio2 = int((capture.getAspectRatio() + 0.005) * 100) _info = xbmc.getInfoLabel('Player.Process(VideoDAR)') _info2 = xbmc.getInfoLabel('Player.Process(videoheight)') diff --git a/addon.xml b/addon.xml index 0c0c978..3aa4c05 100644 --- a/addon.xml +++ b/addon.xml @@ -1,8 +1,14 @@ - + + + + + + + executable diff --git a/imdb.py b/imdb.py new file mode 100644 index 0000000..b68fdbb --- /dev/null +++ b/imdb.py @@ -0,0 +1,30 @@ +import requests +from bs4 import BeautifulSoup + + +def getOriginalAspectRatio(query): + BASE_URL = "https://www.imdb.com/" + HEADERS = { + 'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'} + + URL = BASE_URL + "find/?q={}".format(query) + searchpage = requests.get(URL, headers=HEADERS) + + soup = BeautifulSoup(searchpage.text, 'lxml') + + if soup.css.select('.ipc-metadata-list-summary-item__t'): + # we have matches, pick the first one + title_url = soup.css.select( + '.ipc-metadata-list-summary-item__t')[0].get('href') + + URL = BASE_URL + title_url + + titlepage = requests.get(URL, headers=HEADERS) + + soup = BeautifulSoup(titlepage.text, 'lxml') + + aspect_ratio_full = soup.find( + attrs={"data-testid": "title-techspec_aspectratio"}).css.select(".ipc-metadata-list-item__list-content-item")[0].decode_contents() + aspect_ratio = aspect_ratio_full.split(':')[0].replace('.', '') + + return aspect_ratio diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index c91ec82..c245675 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -28,4 +28,8 @@ msgstr "Automatically remove black bars" msgctxt "#32003" msgid "Toggle status" -msgstr "Toggle status" \ No newline at end of file +msgstr "Toggle status" + +msgctxt "#32004" +msgid "Android workaround (requires internet)" +msgstr "Android workaround (requires internet)" \ No newline at end of file diff --git a/resources/settings.xml b/resources/settings.xml index f308c80..27873ab 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -15,6 +15,11 @@ true + + 0 + false + +