فهرست منبع

[fixed] Downloading did not work for some books (for example Boys in the Valley by Philip Fracassi).

TnS-hun 1 سال پیش
والد
کامیت
54a7f464c7
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      kobo-book-downloader/Kobo.py

+ 8 - 1
kobo-book-downloader/Kobo.py

@@ -335,8 +335,15 @@ class Kobo:
 		for jsonContentUrl in jsonContentUrls:
 			if ( jsonContentUrl[ "DRMType" ] == "KDRM" or jsonContentUrl[ "DRMType" ] == "SignedNoDrm" ) and \
 				( jsonContentUrl[ "UrlFormat" ] == "EPUB3" or jsonContentUrl[ "UrlFormat" ] == "KEPUB" ):
+				# Remove the mysterious "b" query parameter that causes forbidden downloads.
+				url = jsonContentUrl[ "DownloadUrl" ]
+				parsed = urllib.parse.urlparse( url )
+				parsedQueries = urllib.parse.parse_qs( parsed.query )
+				parsedQueries.pop( "b", None )
+				url = parsed._replace( query = urllib.parse.urlencode( parsedQueries, doseq = True ) ).geturl()
+
 				hasDrm = jsonContentUrl[ "DRMType" ] == "KDRM"
-				return jsonContentUrl[ "DownloadUrl" ], hasDrm
+				return url, hasDrm
 
 		message = "Download URL for supported formats can't be found for product '%s'.\n" % productId
 		message += "Available formats:"