initial commit
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								scripts/Moly_hu.zip
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								scripts/Moly_hu.zip
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										0
									
								
								scripts/dummy.paperbook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								scripts/dummy.paperbook
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										44
									
								
								scripts/import-moly.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								scripts/import-moly.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
DATAFILE="/opt/konyvleltar/data/moly.txt"
 | 
			
		||||
INPUTFILE="/opt/konyvleltar/data/moly-input-$RANDOM.txt"
 | 
			
		||||
ERRORFILE="/opt/konyvleltar/data/moly-error.txt"
 | 
			
		||||
 | 
			
		||||
LIBRARY="http://localhost:32452/#paperbooks"
 | 
			
		||||
 | 
			
		||||
META_TMP="/home/calibre/metamoly.tmp"
 | 
			
		||||
COVER_TMP="/home/calibre/covermoly.jpg"
 | 
			
		||||
 | 
			
		||||
DUPES="-d" # "" or "-d"
 | 
			
		||||
RESTRICT_MOLY="" # "" or "--allowed-plugin Moly_hu"
 | 
			
		||||
 | 
			
		||||
if [ -f "$DATAFILE" ];
 | 
			
		||||
then
 | 
			
		||||
    mv "$DATAFILE" "$INPUTFILE"
 | 
			
		||||
    if [ -f "$META_TMP" ]; then rm "$META_TMP"; fi;
 | 
			
		||||
    if [ -f "$COVER_TMP" ]; then rm "$COVER_TMP"; fi;
 | 
			
		||||
    cat "$INPUTFILE" | while read MOLYID
 | 
			
		||||
    do
 | 
			
		||||
        ALREADY_IN=`calibredb --with-library $LIBRARY list --fields id --search "identifiers:moly_hu:$MOLYID" | tail -n +2 | wc -l`
 | 
			
		||||
        if [ $ALREADY_IN -eq 0 ];
 | 
			
		||||
        then
 | 
			
		||||
            fetch-ebook-metadata $RESTRICT_MOLY --identifier moly_hu:$MOLYID -c "$COVER_TMP" -o > "$META_TMP"
 | 
			
		||||
            if [ -s "$META_TMP" ]; # not empty
 | 
			
		||||
            then
 | 
			
		||||
                if [ -s "$COVER_TMP" ]; # not empty
 | 
			
		||||
                then
 | 
			
		||||
                COVER="--cover $COVER_TMP"
 | 
			
		||||
                else
 | 
			
		||||
                COVER=""
 | 
			
		||||
                fi
 | 
			
		||||
                calibredb --with-library $LIBRARY add $DUPES --identifier moly_hu:$MOLYID $COVER dummy.paperbook
 | 
			
		||||
                ID=`calibredb --with-library $LIBRARY list --fields id --search "identifiers:moly_hu:$MOLYID" | grep -v id`
 | 
			
		||||
                calibredb --with-library $LIBRARY set_metadata $ID "$META_TMP"
 | 
			
		||||
            else
 | 
			
		||||
                echo $MOLYID >> $ERRORFILE
 | 
			
		||||
            fi
 | 
			
		||||
            if [ -f "$META_TMP" ]; then rm "$META_TMP"; fi;
 | 
			
		||||
            if [ -f "$COVER_TMP" ]; then rm "$COVER_TMP"; fi;
 | 
			
		||||
        fi
 | 
			
		||||
    done
 | 
			
		||||
    rm $INPUTFILE
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										44
									
								
								scripts/import-paperbooks.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								scripts/import-paperbooks.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
DATAFILE="/opt/konyvleltar/data/isbn.txt"
 | 
			
		||||
INPUTFILE="/opt/konyvleltar/data/isbn-input-$RANDOM.txt"
 | 
			
		||||
ERRORFILE="/opt/konyvleltar/data/isbn-error.txt"
 | 
			
		||||
 | 
			
		||||
LIBRARY="http://localhost:32452/#paperbooks"
 | 
			
		||||
 | 
			
		||||
META_TMP="/home/calibre/meta.tmp"
 | 
			
		||||
COVER_TMP="/home/calibre/cover.jpg"
 | 
			
		||||
 | 
			
		||||
DUPES="-d" # "" or "-d"
 | 
			
		||||
RESTRICT_MOLY="" # "" or "--allowed-plugin Moly_hu"
 | 
			
		||||
 | 
			
		||||
if [ -f "$DATAFILE" ];
 | 
			
		||||
then
 | 
			
		||||
    mv "$DATAFILE" "$INPUTFILE"
 | 
			
		||||
    if [ -f "$META_TMP" ]; then rm "$META_TMP"; fi;
 | 
			
		||||
    if [ -f "$COVER_TMP" ]; then rm "$COVER_TMP"; fi;
 | 
			
		||||
    cat "$INPUTFILE" | while read ISBN
 | 
			
		||||
    do
 | 
			
		||||
        ALREADY_IN=`calibredb --with-library $LIBRARY list --fields isbn --search isbn:$ISBN | grep -v isbn | wc -l`
 | 
			
		||||
        if [ $ALREADY_IN -eq 0 ];
 | 
			
		||||
        then
 | 
			
		||||
            fetch-ebook-metadata $RESTRICT_MOLY --isbn $ISBN -c "$COVER_TMP" -o > "$META_TMP"
 | 
			
		||||
            if [ -s "$META_TMP" ]; # not empty
 | 
			
		||||
            then
 | 
			
		||||
                if [ -s "$COVER_TMP" ]; # not empty
 | 
			
		||||
                then
 | 
			
		||||
                COVER="--cover $COVER_TMP"
 | 
			
		||||
                else
 | 
			
		||||
                COVER=""
 | 
			
		||||
                fi
 | 
			
		||||
                calibredb --with-library $LIBRARY add $DUPES --isbn $ISBN $COVER dummy.paperbook
 | 
			
		||||
                ID=`calibredb --with-library $LIBRARY list --fields id --search isbn:$ISBN | grep -v id`
 | 
			
		||||
                calibredb --with-library $LIBRARY set_metadata $ID "$META_TMP"
 | 
			
		||||
            else
 | 
			
		||||
                echo $ISBN >> $ERRORFILE
 | 
			
		||||
            fi
 | 
			
		||||
            if [ -f "$META_TMP" ]; then rm "$META_TMP"; fi;
 | 
			
		||||
            if [ -f "$COVER_TMP" ]; then rm "$COVER_TMP"; fi;
 | 
			
		||||
        fi
 | 
			
		||||
    done
 | 
			
		||||
    rm $INPUTFILE
 | 
			
		||||
fi
 | 
			
		||||
		Reference in New Issue
	
	Block a user