Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 07-26-2020, 08:40 AM   #1
iamashwin99
Junior Member
iamashwin99 began at the beginning.
 
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]
iamashwin99 is offline   Reply With Quote
Old 07-26-2020, 10:46 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,113
Karma: 57259780
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
theducks is online now   Reply With Quote
Advert
Old 07-26-2020, 12:46 PM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 75,089
Karma: 131686272
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by iamashwin99 View Post
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.
Where did these eBooks with the rubbish metadata come from?
JSWolf is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kute File Monitor: A smarter file-trigger based launcher NiLuJe Kobo Developer's Corner 221 04-28-2023 01:37 PM
Troubleshooting Convert Metadata file .AZW3R into .MBP or "MyClippings.txt" into a Metadata file LittleBeard Amazon Kindle 25 04-13-2020 10:41 AM
Send to device based on Metadata DavidTC Calibre 0 09-18-2011 01:18 PM
rename files based on metadata jchrist Calibre 10 09-14-2010 10:28 AM


All times are GMT -4. The time now is 11:19 AM.


MobileRead.com is a privately owned, operated and funded community.