01-17-2011, 08:02 AM | #91 | |
Member
Posts: 10
Karma: 10
Join Date: Dec 2008
Device: none
|
Quote:
I've written a small script to automatically add a random ASIN and the EBOK tag to a .mobi file under linux. I'm pretty sure the range of my random number is not great, but it works well. Code:
#!/bin/bash FLOOR=1000000 number=0 #initialize NUMBER=$[ ( $RANDOM % 9999999 ) + 1000000 ] str=$(printf "%04d" $NUMBER) ASIN="B00" ASIN=$ASIN$str /path/to/mobi2mobi/binary/mobi2mobi --outfile "$1" --exthtype 113 --exthdata $ASIN "$1" /path/to/mobi2mobi/binary/mobi2mobi --outfile "$1" --addexthtype 501 --exthdata "EBOK" "$1" Last edited by Edzilla; 01-17-2011 at 08:32 AM. |
|
01-17-2011, 01:15 PM | #92 |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
So as long as the coverart is setup correctly in Calibre, it should work fine then right?
I hope you don't mind, but I rewrote your bash file to handle files in batch. Just run this from the directory where all your ebooks are. I haven't tested it though because I don't have mobi2mobi working on my Mac yet haha. Lemme know if you run into any problems. Code:
#!/bin/bash count1=0 asin1="B00" FILES="*.mobi" for g in $FILES do if [ "$g" ] then count1=$[$count1+1] continue fi done rand1=$[1000-$count1] while [ $rand1 -lt 1000 ] do rand1=$[ (( $RANDOM % ( $[ 9999 - 1000 ] + 1 ) ) + 1000) - $count1 ] done rand2=$[ ( $RANDOM % ( $[ 999 - 100 ] + 1 ) ) + 100 ] for f in $FILES do if [ "$f" ] then /path/to/mobi2mobi/binary/mobi2mobi --outfile "$f" --exthtype 113 --exthdata $asin1$rand2$rand1 "$f" /path/to/mobi2mobi/binary/mobi2mobi --outfile "$f" --addexthtype 501 --exthdata "EBOK" "$f" rand1=$[$rand1+1] continue fi done |
Advert | |
|
01-17-2011, 02:53 PM | #93 | |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
Quote:
If this is true, I'll see if I can remember enough python so I can write a script that will search amazon and download the correct ASIN numbers for the books. If someone with an android will do a test for me: I need to know if a pBook ASIN number will work, or if it needs to be in the actual Kindle store. |
|
01-17-2011, 03:05 PM | #94 | |
Grand Sorcerer
Posts: 27,947
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Last edited by DiapDealer; 01-17-2011 at 03:08 PM. |
|
01-17-2011, 04:23 PM | #95 |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
So I tested it on my wife's Ipod touch. I put a legit ASIN from the kindle store and it used the product image affiliated with that book instead of the embedded image from calibre.
I'll try it with a non Kindle store book with a real ASIN and let you know... |
Advert | |
|
01-17-2011, 04:32 PM | #96 |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
With the book that I gave a pBook ASIN number it just defaulted to the embedded image on both the ipod touch and K4MAC.
I'm guessing it would do the same for a random ASIN number, but I don't have mobi2mobi on this computer, so I'll have to try it a little later... |
01-18-2011, 01:48 AM | #97 |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
Ok, I was able to get it. This is for windows only though. I'll work on the *nix version soon...
Here's what you'll need to do: -python-amazon-product-api (It's not too hard to install "easy_install python-amazon-product-api" if you have python setup in your PATH properly, if it has dependency problems, you'll have to install http://users.skynet.be/sbi/libxml-python/ and then run that command again) -All your mobi files in one directory -Save simple python script (attached) in the folder where you have your mobi files -An Amazon Product Advertising account (https://affiliate-program.amazon.com...tail/main.html) -Put the keys you get from this into the asin_search.py file -Save this file as a .bat in the same folder as above Code:
@echo off & setLocal EnableDELAYedExpansion del temp*.txt>null 2>&1 set "asin1=B00" set /a count=0 for /f %%a IN ('dir /b *.mobi') do (set /a count=count+1) echo Number of files: %count% set /a diff=((9999-%count%) - 1000) + 1 set /a divisor = 32767 / %diff% set /a diff2=(999 - 100) + 1 set /a divisor2 = 32767 / %diff2% :Random1 set /a asin2=%random% / %divisor% if /i %asin2% GTR 9999 goto Random1 if /i %asin2% LSS 1000 goto Random1 :Random2 set /a asin3=%random% / %divisor2% if /i %asin3% GTR 999 goto Random2 if /i %asin3% LSS 100 goto Random2 set /a temp1=!asin2! for /f "delims= " %%b IN ('dir /b *.mobi') do ( C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe --outfile "%%b" --delexthtype 113 "%%b">null 2>&1 C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe --outfile "%%b" --delexthtype 501 "%%b">null 2>&1 C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe "%%b" > temp1.txt findstr /i "longtitle" temp1.txt > temp2.txt set /p title1=<temp2.txt set title1=!title1:~11! findstr /i "item: 100" temp1.txt > temp3.txt set /p author1=<temp3.txt set author1=!author1:~33! python asin_search.py "!title1!" "!author1!" >temp4.txt set /p temp2=<temp4.txt set temp2=!temp2:~0! call :movement %%b ) :movement find /c /i "b0" "temp4.txt">null 2>&1 if !ERRORLEVEL! EQU 0 goto :real if !errorlevel! equ 1 goto :fake :fake C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe --outfile "%%b" --exthtype 113 --exthdata "!asin1!!asin3!!temp1!" "%%b">null 2>&1 echo Gave a fake ASIN number to: !title1!. It's new number is !asin1!!asin3!!temp1! set /a temp1=!temp1!+1 goto final :real C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe --outfile "%%b" --exthtype 113 --exthdata "!temp2!" "%%b">null 2>&1 echo Gave a real ASIN number to: !title1!. It's new number is !temp2! :final C:\Users\m0ngr31\desktop\kindle\mobi2mobi.exe --outfile "%%b" --addexthtype 501 --exthdata "EBOK" "%%b">null 2>&1 del temp*.txt>null 2>&1 -Run the file! Should be pretty straight-forward. It'll go through all the mobi files you have, search for the title and author of every book (so you need to have them correct in the meta info) on the kindle store and if it's there, it'll download the correct ASIN number, if it isn't there, it'll insert a random number. It was kind of slopped together, and it's not perfect, but it seemed for me. Let me know if you run to any problems. --edit It wouldn't let me upload my python file, so save this as asin_search.py in the working directory Code:
import sys from amazonproduct import API AWS_KEY = 'put your own key here' SECRET_KEY = 'put your secret key here' api = API(AWS_KEY, SECRET_KEY, "us") node = api.item_search('KindleStore', Title=sys.argv[1], Author=sys.argv[2]) for book in node.Items.Item: print '%s' % (book.ASIN) Last edited by m0ngr31; 01-18-2011 at 01:50 AM. |
01-18-2011, 09:56 AM | #98 | |
Addict
Posts: 202
Karma: 10802
Join Date: Sep 2010
Device: Kindle Paperwhite, iPhone 5, iPad Air, Nexus 7
|
Quote:
|
|
01-18-2011, 03:17 PM | #99 | |
Member
Posts: 10
Karma: 10
Join Date: Dec 2008
Device: none
|
Quote:
I didn't want to do a batch script because it generates a new asin every time it's used. If you copy the file to your device then run it again, the two copies would not sync |
|
01-18-2011, 03:39 PM | #100 |
Connoisseur
Posts: 66
Karma: 3056
Join Date: Dec 2010
Device: Kindle Paperwhite
|
Yeah, it was meant as a "run once" type of program. If you run it once and use those as the original files, you shouldn't run into any problems.
I'll write a bash script in the next day or two that will do the same as the windows one I wrote last night. That way if it's a book sold on the amazon store at least it'll have the same ASIN number. That way it won't change if you run it again. |
01-19-2011, 04:46 AM | #101 |
Addict
Posts: 202
Karma: 10802
Join Date: Sep 2010
Device: Kindle Paperwhite, iPhone 5, iPad Air, Nexus 7
|
So if the book isn't in Kindle store, do you just create your own ASIN? Someone mentioned I can use the pBook (does that mean printed?) but not all have one.
|
01-19-2011, 05:02 AM | #102 |
Member
Posts: 10
Karma: 10
Join Date: Dec 2008
Device: none
|
|
01-19-2011, 05:10 AM | #103 |
Addict
Posts: 202
Karma: 10802
Join Date: Sep 2010
Device: Kindle Paperwhite, iPhone 5, iPad Air, Nexus 7
|
And xxxxxxx can be any combination of alpha-numeric characters? I could use the title of book so im sure there arent any conflicts.
|
01-19-2011, 05:41 AM | #104 |
Member
Posts: 10
Karma: 10
Join Date: Dec 2008
Device: none
|
I'm not sure. When generating an ASIN, I've only used random numbers, but an "official" ASIN contains both numbers and letters (B004G60EHS), so it probably does work. You should try and see if it does.
|
01-19-2011, 06:39 AM | #105 |
Addict
Posts: 202
Karma: 10802
Join Date: Sep 2010
Device: Kindle Paperwhite, iPhone 5, iPad Air, Nexus 7
|
Hurrah it works! Great discovery. Thanks to all.
|
Tags |
kindle 3, sideloading, sync "furthest page read", whispernet, whispersync |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sideloading MOBI files to Kindle for iPad | GRiker | Devices | 34 | 08-31-2012 06:02 AM |
Whispersync question | stustaff | Amazon Kindle | 11 | 12-15-2010 08:39 PM |
Sideloading with Kindle app? | Maggie Leung | Apple Devices | 10 | 08-01-2010 09:46 PM |
Anyone with a U.S. only K2 have whispersync access outside the U.S? | Sheebrook | Amazon Kindle | 3 | 06-10-2010 08:58 PM |
Whispersync question | gandor62 | Amazon Kindle | 3 | 03-12-2010 03:54 PM |