Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Get hash code from file name to find thumbnails
#1
Hi.

I want to know the hash coded name for a thumbnail.

I have found this in the wiki :

http://wiki.xbmc.org/index.php?title=Thumbnails#Hashing

So I make some tests with Python :

Code:
def get_crc32( string ):
    string = string.lower()
    bytes = bytearray(string.encode())
    crc = 0xffffffff;
    for b in bytes:
        crc = crc ^ (b << 24)
        for i in range(8):
            if (crc & 0x80000000 ):
                crc = (crc << 1) ^ 0x04C11DB7
            else:
                crc = crc << 1;
        crc = crc & 0xFFFFFFFF
    return '%08x' % crc

print ("CRC32=", get_crc32("F:\\Videos\\Nosferatu.avi"))

As espected, hash code is :

Code:
CRC32= 2a6ec78d

But I want to find the thumbnail for this picture : C:\TV\TF1.tbn

So same function in Python :

Code:
print ("CRC32=", get_crc32("C:\\TV\\TF1.tbn"))

And result :

Code:
CRC32= 2a6ec78d

But the correct file in thumbnail folder is XBMC\userdata\Thumbnails\Video\11c05c994.tbn

Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#2
There is a xbmc module for getting the hash location.
See the py-docs.

Example:
https://github.com/XBMC-Addons/script.ar...loader#L80

Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
Thanks Martijn.

But I was doing this outside XBMC and as the code is given in the wiki, I want to understand how XBMC get hash name and not use built in function Tongue
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#4
Ah ok Smile
Possibly some one can point you to the source code in XBMC
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
this has been all changed in master. however;

see CFileItem::GetCachedXXXThumb() for the code in eden (FileItem.cpp)
Reply
#6
Thanks Spiff but I don't find the function that give 11c05c994 for the filename C:\TV\TF1.tbn

In FileItem.cpp

Code:
CStdString CFileItem::GetCachedArtistThumb() const
{
  return CThumbnailCache::GetArtistThumb(*this);
}

In ThumbnailCache.cpp

Code:
CStdString CThumbnailCache::GetArtistThumb(const CFileItem &item)
{
  return GetArtistThumb(item.GetLabel());
}
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#7
It doesn't give it for a .tbn file. It gives it for the media file. i.e. crc the media file and that's the thumb to use.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#8
OK but I want to write a Pyhton function that give the hash codec name for a fullpath file.

Exactly the same that in the wiki :

http://wiki.xbmc.org/index.php?title=Thumbnails#Hashing

But, as spiff said, the function given is deprecated.

So where can I found in the cpp files, the function that give 11c05c994 (and store thumbnail in XBMC\userdata\Thumbnails\Video\11c05c994.tbn) for the filename C:\TV\TF1.tbn ?

Thanks.
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#9
Again, that is not the filename that produced said thumb. TF1.avi if a video file or C:\TV\TF1\ if a folder would have been used.

The cpp file is the one you quote above (ThumbnailCache.cpp) - you'll need an older version, eg look in the Eden branch on github.

https://github.com/xbmc/xbmc/blob/Eden/x...lCache.cpp

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#10
Sorry but I don't undersand Sad

What I do :

- Make a directory C:\TV
- Add a M3U file : C:\TV\TF1.m3u
- Add a TBN file : C:\TV\TF1.tbn to specify the thumbnail to XBMC
- Add C:\TV to XBMC source with no scrapper
- In XBMC, first time I access this sourcce, XBMC copy C:\TV\TF1.tbn to XBMC\userdata\Thumbnails\Video\11c05c994.tbn
- If I want to update my TF1.tbn thumbnail, I overwrite C:\TV\TF1.tbn but XBMC don't use it and still display 11c05c994.tbn
- So I have to manually copy my new TF1.tbn to XBMC\userdata\Thumbnails\Video\11c05c994.tbn

But when you have a lot a files in Thumbnails directories, it's hard to know how the searched thumbnail is named.

So I was thinking of a small python code that give me 11c05c994 when I pass C:\TV\TF1.tbn or TF1.tbn (don't know if thumbnail name is based on filename (with or withour extension) or fullpath filename.

Hope that is clearer for you guys Wink

Thanks.
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#11
You pass it C:\TV\TF1.m3u
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#12
Get it and it's so logical !!!

So with this code :

Code:
def get_crc32( string ):
    string = string.lower()
    bytes = bytearray(string.encode())
    crc = 0xffffffff;
    for b in bytes:
        crc = crc ^ (b << 24)
        for i in range(8):
            if (crc & 0x80000000 ):
                crc = (crc << 1) ^ 0x04C11DB7
            else:
                crc = crc << 1;
        crc = crc & 0xFFFFFFFF
    return '%08x' % crc

print ("CRC32=", get_crc32("C:\\TV\\TF1.m3u"))

Get the correct result :

Code:
CRC32= 1c05c994

But the thumbnail get a one more 1 at first position :

XBMC\userdata\Thumbnails\Video\11c05c994.tbn
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#13
The first character is re-used as the subfolder.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#14
OK.

Guess that I haven't subdirectory because I was using a fresh XBMC setup with only 1 file (TF1.m3u) so no subfolder was created Big Grin

Thanks a lot for your answers.
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply

Logout Mark Read Team Forum Stats Members Help
Get hash code from file name to find thumbnails0
This forum uses Lukasz Tkacz MyBB addons.