repub icon indicating copy to clipboard operation
repub copied to clipboard

[5.5.1] Files all downloaded as "download.epub"

Open Shohreh opened this issue 3 months ago • 2 comments

Hello,

For a few days now, Chrome downloads all files as "download.epub" instead of using the user-provided title like it did before.

I guess it's due to some update from Chrome (FWIW, version 140.0.7339.128).

No biggie, but it'd be nice to have the actual title as filename.

Cheers,

Image

Shohreh avatar Sep 20 '25 12:09 Shohreh

This is so strange, because I can't reproduce it, nor can I find an reason why this would be the case. There are a few places where if the library can't find a title, it replaces it with a default title, but never is that string "download". I both had the filename appropriately set if pulled from the page, or when specified manually.

I tried googling, but couldn't find any evidence of this happening. Have you potentially added other chrome extensions recently? There is this api that allows extensions to rename downloads, so potentially another extension is overriding the file name?

If you can't find any other cause, I might suggest trying to disable all of your other extensions and seeing if the behavior persists. If it does, then I'll try to find another explanation. If that fixes it, then one of those extensions is at fault.

Sorry I can't offer more help right now.

erikbrinkman avatar Sep 21 '25 15:09 erikbrinkman

If you can't find any other cause, I might suggest trying to disable all of your other extensions and seeing if the behavior persists. If it does, then I'll try to find another explanation. If that fixes it, then one of those extensions is at fault.

I tried disabling one by one the few extensions that updated recently, but it made no difference.

If I can figure it out, I'll report back. Thanks for the help.

-- Edit: In the meantime, a bit of Python to rename "download*.epub" files from metadata:

import os
import ebookmeta
import glob
from pathvalidate import sanitize_filename
#import wx

for item in glob.glob("download*.epub"):
	print(f"Handling {item}")
	meta = ebookmeta.get_metadata(item)
	clean_name = sanitize_filename(meta.title, platform="windows") + ".epub"
	#FileExistsError: [WinError 183] Cannot create a file when that file already exists
	if not os.path.isfile(clean_name):
		os.rename(item, clean_name)
		print(clean_name)
	else:
		print("File already exists:", clean_name)

print("Hit any key")
x = input()
#app = wx.App()
#wx.MessageBox("Done.", 'Info', wx.OK | wx.ICON_INFORMATION)

Edit: wxPython edition. To hide console on Windows, rename extension to .pyw

#rename *.epub with title in metadata, and then rename .epub to .kepub.epub

import sys,os, wx
import ebookmeta
import glob
from pathvalidate import sanitize_filename
import pathlib

class ListBoxFrame(wx.Frame):
	def __init__(self, *args, **kwargs):  
		super().__init__(None, -1,title='Bulk *.epub Rename')
		
		self.Centre()

		panel = wx.Panel(self, id=wx.ID_ANY)

		sizer = wx.BoxSizer(wx.VERTICAL)

		self.lb1 = wx.ListBox(panel, id=wx.ID_ANY, style=(wx.LB_SINGLE | wx.LB_ALWAYS_SB))
		sizer.Add(self.lb1,1, wx.ALL | wx.EXPAND ,5)

		self.run_btn = wx.Button(panel, id=wx.ID_ANY, label="Run")
		sizer.Add(self.run_btn,0, wx.EXPAND)
		self.run_btn.Bind(wx.EVT_BUTTON, self.OnRunButtonClick)

		panel.SetSizer(sizer)
		panel.Layout()

	def OnRunButtonClick(self,event):
		self.run_btn.Disable()

		for item in glob.glob("download*.epub"):
			self.lb1.Append(f"Handling {item}")

			meta = ebookmeta.get_metadata(item)
			clean_name = sanitize_filename(meta.title, platform="windows") + ".epub"
			if not os.path.isfile(clean_name):
				os.rename(item, clean_name)
				self.lb1.Append(clean_name)
			else:
				self.lb1.Append("File already exists:", clean_name)

		#turn processed .epub into .kepub.epub
		for item in glob.glob("*.epub"):
			self.lb1.Append(f"Handling {item}")
			if ".kepub" not in item:
				p = pathlib.Path(item)
				new_name = p.rename(p.with_suffix('.kepub.epub'))
				self.lb1.Append("Renamed:", new_name)
			else:
				self.lb1.Append("No need to rename extension")

		title = "Done."
		self.lb1.Append(title)
		self.SetTitle(title)

		self.run_btn.Enable()
			
app = wx.App()
ListBoxFrame().Show()
app.MainLoop()

Shohreh avatar Sep 22 '25 07:09 Shohreh