Req Detect tmdb#id in filename
#1
Rainbow 
Hi world,

I'm a kodi user since sooo long (a XBMC user on xbox1 to be precise !) ... and I'ml sooo grateful for the result now in 2022.

Since some years, I have more and more movies not found by scrapper, even when I copy-paste the exact title from TMDB ... annoying ...

So here is the idea : the scrapper could take the TMDB #id directly from filename when detected ... ie : "LotR - Two Towers (2002)(tmdb#122).mkv"

Something like that already exist during movie searching but it's not really easy to use imo.

Thanks for reading  Music

Z3b
Reply
#2
(2022-05-30, 00:42)Z3b2G Wrote: Since some years, I have more and more movies not found by scrapper, even when I copy-paste the exact title from TMDB
Other options are...

1. Use a Parsing NFO file... https://kodi.wiki/view/NFO_files/Parsing
2. Use the Search in Kodi... https://kodi.wiki/view/Add-on:The_Movie_...hon#Search
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki) || Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#3
(2022-05-30, 01:00)Karellen Wrote:
(2022-05-30, 00:42)Z3b2G Wrote: Since some years, I have more and more movies not found by scrapper, even when I copy-paste the exact title from TMDB
Other options are...

1. Use a Parsing NFO file... https://kodi.wiki/view/NFO_files/Parsing
2. Use the Search in Kodi... https://kodi.wiki/view/Add-on:The_Movie_...hon#Search
Yes, I know ... but this is not really nice imho.

Thanks  Angel
Reply
#4
Brick 
The funy part is that looks already here ... 

from https://github.com/xbmc/metadata.themovi...er/tmdb.py
Quote:def _parse_media_id(title):
if title.startswith('tt') and title[2:].isdigit():
return {'type': 'imdb', 'id':title} # IMDB ID works alone because it is clear
title = title.lower()
if title.startswith('tmdb/') and title[5:].isdigit(): # TMDB ID
return {'type': 'tmdb', 'id':title[5:]}
elif title.startswith('imdb/tt') and title[7:].isdigit(): # IMDB ID with prefix to match
return {'type': 'imdb', 'id':title[5:]}
return None

and if i rename my file "tt4574334.mkv" ... magic ... thie file is now a well known TV show ...

...work in progress ...
Reply
#5
I'm not a dev python, but I think something like that could work :

def _parse_media_id(title):
    if title.startswith('tt') and title[2:].isdigit():
        return {'type': 'imdb', 'id':title} # IMDB ID works alone because it is clear
    title = title.lower()
    if title.startswith('tmdb/') and title[5:].isdigit(): # TMDB ID
        return {'type': 'tmdb', 'id':title[5:]}
    elif title.startswith('imdb/tt') and title[7:].isdigit(): # IMDB ID with prefix to match
        return {'type': 'imdb', 'id':title[5:]}
    elif title.find("(tmdb#")!=-1    and title[title.find("(tmdb#")+6:-1].isdigit():
      return {'type': 'tmdb', 'id':title[title.find("(tmdb#")+6:-1]}
    return None
Reply
#6
@Z3b2G

Someone has asked about this also a few days ago. See the reply by @rmrector ... https://forum.kodi.tv/showthread.php?tid...pid3098741
And code proposal a few posts further down.

If you make the change to the code in your local files, you could test and if it works submit a pull request. rmrector is pretty busy these days, so I am sure he will appreciate the help.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki) || Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#7
as i post 2 posts below, i hope  my code works with imdb number (with the restrictition of the date position)
if you want the tmbd number working the same way 
try to add in   addons\metadata.themoviedb.org.python\python\lib\tmdbscraper\tmdb.py  
def _parse_media_id(title):
    m=re.search(r"(tt\d+)",title)
    if m: return {'type': 'imdb', 'id':m.group()}
   m=re.search(r"tmdb[\/#](\d+)",title)                 #work with tmdb/number and tmdb#number
    if m: return {'type': tmdb', 'id':m.group()}
368312 (thread)

this works (i hope) with tmdb python scraper and this code will be erase when this scaper will be update by kodi updater addon
Reply
#8
soooo great ... I will test that asap.

if this works as I think it will, I will finally have THE ultimate solution for movie scrapping ! ... perfect, ty for the help.

Thanks to everyone  Cool
Z3b
Reply
#9
def _parse_media_id(title):
m=re.search(r"(tt\d+)",title)
if m: return {'type': 'imdb', 'id':m.group()}
m=re.search(r"tmdb[\/#](\d+)",title) #work with tmdb/number and tmdb#number
if m: return {'type': 'tmdb', 'id':m.group()[5:]}
return None

fix : with tmdb, 'id' should only contain the id ...
( am I wrong ? )
Reply
#10
have you try ?
with m=re.search(r"tmdb[\/#](\d+)",title)     m.group() return the numbers only.
Reply
#11
(2022-05-30, 11:59)michelb2 Wrote: have you try ?
with m=re.search(r"tmdb[\/#](\d+)",title)     m.group() return the numbers only.

I have just test it in python online sandbox and it return the whole pattern ... but you are right : it should not ... Huh

https://pythonsandbox.com/code/pythonsan...jRUM_v0.py
Reply
#12
Dixit python doc :
.group()
returns the part of the string where there was a match

So ...
(Yes, i'm pure newbie to python ... 😁)
Reply
#13
(2022-05-30, 14:03)Z3b2G Wrote: (Yes, i'm pure newbie to python ... 😁)

I'm no developer either, but make sure you are using Python-3 compatible syntax. Python-2 is EOL.
Got a Kodi problem? Provide a full Debug log (wiki) | Usefull pages: First time user (wiki) | Troubleshooting (wiki) | Free content (wiki) | Forum rules (wiki) | VPN policy (wiki)
Reply
#14
ok i try inside kodi200 , i agree with you
m=re.search(r"tmdb[\/#](\d+)",title)
if m: return {'type': 'tmdb', 'id':m.group()[5:]}   is the good syntax

m=re.search(r"tmdb[\/#](\d+)",title)
if m: return {'type': 'tmdb', 'id':m.group(1)}  is a good synax also

(by i am not a python developper either)

m.group() return the whole match
m.group(1) return the first group match inside ()
Reply
#15
Quote:Match.group([group1, ...])
Returns one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (the whole match is returned). If a groupN argument is zero, the corresponding return value is the entire matching string; if it is in the inclusive range [1..99], it is the string matching the corresponding parenthesized group. If a group number is negative or larger than the number of groups defined in the pattern, an IndexError exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is None. If a group is contained in a part of the pattern that matched multiple times, the last match is returned.
ok, so we are noobs ... but we done it !

if m: return {'type': 'tmdb', 'id':m.group(1)}
is far better imo.

I will test that soon, you already test ?

bye.
Reply



Logout Mark Read Team Forum Stats Members Help
Detect tmdb#id in filename0
This forum uses Lukasz Tkacz MyBB addons.