Skip to content

Commit

Permalink
[script.black.bars.never] 1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
osumoclement committed Sep 21, 2024
1 parent 4408c11 commit 4fa1708
Show file tree
Hide file tree
Showing 13 changed files with 461 additions and 0 deletions.
9 changes: 9 additions & 0 deletions script.black.bars.never/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
54 changes: 54 additions & 0 deletions script.black.bars.never/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# BlackBarsNever Kodi Addon - Remove black bars

# How it works

This is an addon that eliminates black bars on KODI, whether hardcoded or the video is just wide format

With addon installed and enabled, it will automatically analyze media on playback and determine
if there are any black bars. The addon will then zoom the media exactly enough to cover the display.

The picture will not be distorted in any way as the zoom is linear,
however, on most media, small parts on the left and right will be cut off. Luckily, everything that's
important tends to fall in the middle of the scene 99% of the time. The advantages of experiencing an
immersive picture that fills the periphery should be enough to overweigh the disdvantage of missing sides.

# Supported platforms

- [x] Linux
- [x] Windows
- [x] macOS and iOS
- [x] Android & Embedded Systems - with workaround method

# Android & Embedded Systems like \*ELEC

Currently, Kodi can't capture sreenshots in Android and Embedded Systems if hardware accelertion is enabled due to some technical limitations. This may change in future and when that happens the addon will work properly like in other platforms. For now there's two options:

1. Disable hardware acceleration (turn off MediaCodec Surface in Android). The problem with this is that Kodi will now use CPU for decoding and playback may be affected to the point of being unwatchable, especially for high bitrate media. Also in the devices I tested, HDR won't work on Android if hardware acceleration is turned on, I am not sure if this affects all of Android.

2. Enable the Android & Embedded Systems Workaround from the addon settings. This feature requires an internet connection to fetch media metadata, and works best if your library adopts a decent naming pattern i.e `Title Year`. Also works properly only if media aspect ratio is unchanged from original (i.e has not been cropped from the original)

# Installation

Download the zip file from [releases](https://github.com/osumoclement/script.black.bars.never/releases)

Launch Kodi >> Add-ons >> Get More >> Install from zip file

You might want to turn off Overscan if your display is a TV by going to settings-> Aspect Ratio -> Just Scan

Feel free to ask any questions, submit feature/bug reports

# Multiple Aspect Ratios in Media

For media with multiple aspect ratios, the addon will notify you of this, and will do nothing. In such cases, I recommend you watch the media as is, since if you change the aspect ratio manually, you may not know where in the media the ratio changes in order to adjust again.
This feature requires internet to work

# Customization

There are a few ways to customize the addon
By default, the addon automatically removes black bars. If you want to change this behavior, you can turn this off in the addon settings. You would then need to manually trigger the addon by manually calling it from elsewhere in Kodi (ie from a Skin) like this `RunScript(script.black.bars.never,toggle)`. You could even map this to a key for convenience

To check the addon status elsewhere from Kodi, use this `xbmcgui.Window(10000).getProperty('blackbarsnever_status')`. The result is either `on` or `off`

# License

BlackBarsNever is [GPLv3 licensed](https://github.com/osumoclement/script.black.bars.never/blob/main/LICENSE). You may use, distribute and copy it under the license terms.
4 changes: 4 additions & 0 deletions script.black.bars.never/addon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from resources.lib.blackbarsnever import Main

if (__name__ == "__main__"):
Main()
33 changes: 33 additions & 0 deletions script.black.bars.never/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.black.bars.never" name="BlackBarsNever" version="1.0.11" provider-name="Clement Osumo">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.20.0"/>
<import addon="script.module.beautifulsoup4" version="4.9.3"/>
<import addon="script.module.soupsieve" version="2.1.0"/>
</requires>
<extension point="xbmc.service" library="addon.py"/>
<extension point="xbmc.python.script" library="addon.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en_US">BlackBarsNever</summary>
<description lang="en_US">This addon eliminates the problem of black bars. If the black bars are hardcoded, the addon will automatically
detect this and remove them. If the video is a wide screen format, the addon will also detect this and remove the black bars too.
</description>
<license>MIT</license>
<language></language>
<forum></forum>
<source>https://github.com/osumoclement/script.black.bars.never</source>
<website>cheensa.com</website>
<email></email>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpeg</fanart>
<screenshot>resources/screenshot-01.jpg</screenshot>
<screenshot>resources/screenshot-02.jpg</screenshot>
</assets>
<news>Updated the addon to use new addon.xml metadata</news>
</extension>
</addon>
1 change: 1 addition & 0 deletions script.black.bars.never/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0 Initial Release
Binary file added script.black.bars.never/fanart.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added script.black.bars.never/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions script.black.bars.never/imdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import requests
from bs4 import BeautifulSoup

import xbmc
import xbmcgui

def notify(msg):
xbmcgui.Dialog().notification("BlackBarsNever", msg, None, 1000)

def getOriginalAspectRatio(title, imdb_number=None):
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'}

if imdb_number and str(imdb_number).startswith("tt"):
URL = "{}/title/{}/".format(BASE_URL, imdb_number)
else:
URL = BASE_URL + "find/?q={}".format(title)
search_page = requests.get(URL, headers=HEADERS)

# lxml parser would have been better but not currently supported in Kodi
soup = BeautifulSoup(search_page.text, 'html.parser')

title_url_tag = soup.select_one(
'.ipc-metadata-list-summary-item__t')
if title_url_tag:
# we have matches, pick the first one
title_url = title_url_tag['href']
imdb_number = title_url.rsplit(
'/title/', 1)[-1].split("/")[0]
# this below could have worked instead but for some reason SoupSieve not working inside Kodi
"""title_url = soup.css.select(
'.ipc-metadata-list-summary-item__t')[0].get('href')
"""

URL = BASE_URL + title_url

title_page = requests.get(URL, headers=HEADERS)
soup = BeautifulSoup(title_page.text, 'html.parser')

# this below could have worked instead but for some reason SoupSieve not working inside Kodi
aspect_ratio_tags = soup.find(
attrs={"data-testid": "title-techspec_aspectratio"})

if aspect_ratio_tags:
aspect_ratio_full = aspect_ratio_tags.select_one(
".ipc-metadata-list-item__list-content-item").decode_contents()

"""aspect_ratio_full = soup.find(
attrs={"data-testid": "title-techspec_aspectratio"}).css.select(".ipc-metadata-list-item__list-content-item")[0].decode_contents()
"""

if aspect_ratio_full:
aspect_ratio = aspect_ratio_full.split(':')[0].replace('.', '')
else:
# check if video has multiple aspect ratios
URL = "{}/title/{}/technical/".format(BASE_URL, imdb_number)
tech_specs_page = requests.get(URL, headers=HEADERS)
soup = BeautifulSoup(tech_specs_page.text, 'html.parser')
aspect_ratio_li = soup.select_one("#aspectratio").find_all("li")
if len(aspect_ratio_li) > 1:
aspect_ratios = []

for li in aspect_ratio_li:
aspect_ratio_full = li.select_one(
".ipc-metadata-list-item__list-content-item").decode_contents()

aspect_ratio = aspect_ratio_full.split(':')[0].replace('.', '')
sub_text = li.select_one(".ipc-metadata-list-item__list-content-item--subText").decode_contents()

if sub_text == "(theatrical ratio)":
xbmc.log("using theatrical ratio " + str(aspect_ratio), level=xbmc.LOGINFO)
return aspect_ratio


aspect_ratios.append(aspect_ratio)

return aspect_ratios

return aspect_ratio
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Black Bars Never language file
# Addon Name: Black Bars Never
# Addon id: script.black.bars.never
# Addon Provider: Clement Osumo

msgid ""
msgstr ""
"Project-Id-Version: Black Bars Never\n"
"Report-Msgid-Bugs-To: Clement Osumo\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-06-18 10:08+0000\n"
"Last-Translator: Clement Osumo\n"
"Language-Team: English (United States)\n"
"Language: en_us\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.8\n"

msgctxt "#32001"
msgid "General"
msgstr "General"

msgctxt "#32002"
msgid "Automatically remove black bars"
msgstr "Automatically remove black bars"

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

msgctxt "#32004"
msgid "Workaround for Android & Embedded (requires internet)"
msgstr "Workaround for Android & Embedded (requires internet)"
Loading

0 comments on commit 4fa1708

Please sign in to comment.