Skip to content

Commit

Permalink
Added Android workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Clement Osumo committed Jun 20, 2023
1 parent 1e7ba2a commit e8aecc1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
14 changes: 12 additions & 2 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)')
Expand Down
8 changes: 7 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.black.bars.never" name="BlackBarsNever" version="1.0.4" provider-name="Clement Osumo">
<addon id="script.black.bars.never" name="BlackBarsNever" version="1.0.5" provider-name="Clement Osumo">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
<requires>
<import addon="script.module.requests" version="2.20.0"/>
</requires>
<requires>
<import addon="script.module.beautifulsoup4" version="4.9.3"/>
</requires>
<extension point="xbmc.service" library="addon.py"/>
<extension point="xbmc.python.script" library="addon.py">
<provides>executable</provides>
Expand Down
30 changes: 30 additions & 0 deletions imdb.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ msgstr "Automatically remove black bars"

msgctxt "#32003"
msgid "Toggle status"
msgstr "Toggle status"
msgstr "Toggle status"

msgctxt "#32004"
msgid "Android workaround (requires internet)"
msgstr "Android workaround (requires internet)"
5 changes: 5 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<close>true</close>
</control>
</setting>
<setting help="" id="android_workaround" label="32004" type="boolean">
<level>0</level>
<default>false</default>
<control type="toggle"/>
</setting>
</group>
</category>
</section>
Expand Down

0 comments on commit e8aecc1

Please sign in to comment.