Last active
September 3, 2020 17:14
-
-
Save satyadeepk/0b074f09bff2cbf0f1bfa02762bf1eb6 to your computer and use it in GitHub Desktop.
Kodi script to auto resume last playing video in last 1 hour on boot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Place this file in /home/osmc/.kodi/userdata | |
## Original at https://www.reddit.com/r/kodi/comments/6x7898/how_to_automatically_start_playing_an_inprogress/ | |
import time | |
time.sleep(10) | |
import os | |
import sqlite3 | |
import sys | |
import xbmc | |
dbFile = os.path.expanduser('/home/osmc/.kodi/userdata/Database/MyVideos116.db') | |
if not os.path.isfile(dbFile): | |
print('Kodi videos database not found') | |
sys.exit(1) | |
dbConn = sqlite3.connect(dbFile) | |
cur = dbConn.cursor() | |
cur.execute(''' | |
select path.strPath || files.strFilename | |
from files | |
left join path on files.idPath = path.idPath | |
where datetime(files.lastPlayed) >= datetime('now', '-1 Hour') | |
order by files.lastPlayed desc | |
limit 1 | |
''') | |
video = cur.fetchone() | |
if video: | |
url = video[0] | |
print('Resuming "%s"' % url) | |
xbmc.executebuiltin('Notification("%s", "%s", %s)' % ( "Resuming video", url[:50]+"...", 10000) ) | |
if "netflix" in url: #Wait for netfilx background service to initialize | |
time.sleep(30) | |
if "youtube" in url: | |
url = url.replace("plugin://plugin.video.youtube/play/", "", 1) | |
xbmc.executebuiltin('PlayMedia(%s,resume)' % url) | |
sys.exit(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put in /boot/config.txt | |
gpu_mem_1024=256 | |
#hdmi_ignore_cec_init=1 | |
disable_overscan=1 | |
start_x=1 | |
disable_splash=1 | |
gpu_mem_256=112 | |
gpu_mem_512=144 | |
sdtv_aspect=1 | |
# HDMI output mode will be used, even if no HDMI monitor is detected | |
hdmi_force_hotplug=1 | |
# Set monitor mode to DMT | |
hdmi_group=2 | |
# Set monitor resolution to 1360x768 @ 60.00Hz | |
hdmi_mode=39 | |
#hdmi_ignore_edid=0xa5000080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please make this file available to others | |
# by sending it to <[email protected]> | |
# | |
# this config file was automatically generated | |
# using lirc-0.9.0(default) on Thu Sep 3 17:19:53 2020 | |
# | |
# contributed by Satyadeep | |
# | |
# brand: LG /home/osmc/lircd.conf | |
# model no. of remote control: AKB74475421 | |
# | |
# Extra Mappings of LG remote | |
# KEY_OK 0x0EF1 # INDEX | |
# KEY_MENU 0x04FB # TEXT | |
# KEY_ZOOM 0x54AB # REVEAL | |
# KEY_INFO 0xA659 # HOLD | |
# KEY_SUBTITLE 0x20DF649B # TIME | |
# KEY_NEXT 0x8679 # BLUE | |
# KEY_PREVIOUS 0x4EB1 # RED | |
# KEY_LANGUAGE 0x20DF46B9 # UPDATE | |
# KEY_HOME 0x20DFDA25 # EXIT | |
# Number keys are also mapped to arrows, back, home, menu etc | |
begin remote | |
name /home/osmc/lircd.conf | |
bits 16 | |
flags SPACE_ENC|CONST_LENGTH | |
eps 30 | |
aeps 100 | |
header 520 601 | |
one 521 1726 | |
zero 521 601 | |
ptrail 522 | |
repeat 9028 2270 | |
pre_data_bits 15 | |
pre_data 0x20DF | |
gap 108309 | |
toggle_bit_mask 0x0 | |
begin codes | |
KEY_VOLUMEUP 0x00FF | |
KEY_VOLUMEDOWN 0x807F | |
KEY_PAUSE 0x5DA2 | |
KEY_PLAY 0x0DF2 | |
KEY_RIGHT 0x609F | |
KEY_LEFT 0xE01F | |
KEY_UP 0x02FD | |
KEY_DOWN 0x827D | |
KEY_OK 0x22DD | |
KEY_BACK 0x14EB | |
KEY_STOP 0x8D72 | |
KEY_OK 0x0EF1 | |
KEY_MENU 0x04FB | |
KEY_FASTFORWARD 0x718E | |
KEY_REWIND 0xF10E | |
KEY_ZOOM 0x54AB | |
KEY_INFO 0xA659 | |
KEY_SUBTITLE 0x20DF649B | |
KEY_NEXT 0x8679 | |
KEY_PREVIOUS 0x4EB1 | |
KEY_HOME 0x08F7 | |
KEY_KP1 0x8877 | |
KEY_UP 0x48B7 | |
KEY_KP3 0xC837 | |
KEY_LEFT 0x28D7 | |
KEY_OK 0xA857 | |
KEY_RIGHT 0x6897 | |
KEY_BACK 0xE817 | |
KEY_DOWN 0x18E7 | |
KEY_MENU 0x9867 | |
KEY_LANGUAGE 0x20DF46B9 | |
KEY_HOME 0x20DFDA25 | |
end codes | |
end remote |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment