|
|
#1 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2019
Device: none
|
Get metadata from Libgen based on file md5sum
I have quite a few books that don't have proper metadat and is thus is hard to search and maintain them. I wanted to make a plugin that automatically calculates md5 of a given book and load its metadata from a libgen search.
I have already completed the code to get the md5 and to get data from the libgen, I just wanted some help to wrap it up into a pluggin so that i can clikc a button and the plugin will do the rest. I would really appreciate if some one can guide me to the proper way to make the plugin. (Or if you can point to some other plugin that is similar to this so that I can hack it to do my steps) I have put the code I have come up with so far over here Here is the main idea Code:
import hashlib
import os
import requests
import pandas as pd
def getmd5sum(filename):
md5_hash = hashlib.md5()
a_file = open(filename, "rb")
content = a_file.read()
md5_hash.update(content)
digest = md5_hash.hexdigest()
return digest
def getdatafrommd5(md5):
url ='http://gen.lib.rus.ec/book/index.php?md5=' +md5
print(url)
r = requests.get(url)
if(r.text == "No record with such MD5 hash has been found</body></html>"):
return [-1, -1, -1, -1, -1]
df_list = pd.read_html(r.text) # this parses all the tables in webpages to a list
table = df_list[0]
title = table.loc[table[1] == 'Title:',2].tolist()[0]
author = table.loc[table[1] == 'Author(s):',2].tolist()[0]
publisher = table.loc[table[1] == 'Publisher:',2].tolist()[0]
series = table.loc[table[1] == 'Series:',2].tolist()[0]
year = table.loc[table[1] == 'Year:',2].tolist()[0]
return [title, author, publisher, series, year]
|
|
|
|
|
|
#2 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,269
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
iama... (not trying to rain on your parade )
MD5 only lasts as long as nothing calibre does (can do) touches the file. Touch the Polish or embed metadata feature and the MD5 is obsolete |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,785
Karma: 150249619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Where did these eBooks with the rubbish metadata come from?
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Kute File Monitor: A smarter file-trigger based launcher | NiLuJe | Kobo Developer's Corner | 225 | 10-10-2025 07:31 AM |
| Troubleshooting Convert Metadata file .AZW3R into .MBP or "MyClippings.txt" into a Metadata file | LittleBeard | Amazon Kindle | 25 | 04-13-2020 11:41 AM |
| Send to device based on Metadata | DavidTC | Calibre | 0 | 09-18-2011 02:18 PM |
| rename files based on metadata | jchrist | Calibre | 10 | 09-14-2010 11:28 AM |