Repository: lukasschwab/arxiv.py

Issue:
Error when downloading paper with '/' in short id
# Description
If the short id  of a paper contains a '/' downloading the source or pdf without providing a filename results in  ` FileNotFoundError: [Errno 2] No such file or directory: './hep-ex/0406020v1.Sparticle_Reconstruction_at_LHC.pdf'`

I guess the reason for this is the behaviour of the `_get_default_filename()` method, as it uses as filename the entire `get_short_id` including the '/'. 

Similar for papers with '/' in the title see for example  `search = arxiv.Search(id_list=['1211.0496v1'])`

## Steps to reproduce

```
search = arxiv.Search(id_list=['hep-ex/0406020v1'])
paper = next(search.results())
paper.download_pdf()
```


## Expected behavior
Downloading the source or pdf of a paper without providing the filename should work the same way for every paper. Maybe one could replace all '/' contained with character that can not be confused with a directory (e.g. '.' like in most paper ids).

# Versions

+ `python` version: 3.11.4

+ `arxiv.py` version: 1.4.7



Discussion:

Patch:
diff --git a/arxiv/arxiv.py b/arxiv/arxiv.py
index e6e974e..b1acfbc 100644
--- a/arxiv/arxiv.py
+++ b/arxiv/arxiv.py
@@ -192,9 +192,11 @@ class Result(object):
         A default `to_filename` function for the extension given.
         """
         nonempty_title = self.title if self.title else "UNTITLED"
-        # Remove disallowed characters.
-        clean_title = '_'.join(re.findall(r'\w+', nonempty_title))
-        return "{}.{}.{}".format(self.get_short_id(), clean_title, extension)
+        return '.'.join([
+            self.get_short_id().replace("/", "_"),
+            re.sub(r"[^\w]", "_", nonempty_title),
+            extension
+        ])
 
     def download_pdf(self, dirpath: str = './', filename: str = '') -> str:
         """
diff --git a/setup.py b/setup.py
index efbf095..8b1bdfe 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup
 
-version = '1.4.7'
+version = '1.4.8'
 
 with open('README.md', 'r') as fh:
     long_description = fh.read()


Test patch:
diff --git a/tests/test_download.py b/tests/test_download.py
index 6c825b7..407597a 100644
--- a/tests/test_download.py
+++ b/tests/test_download.py
@@ -10,6 +10,7 @@ class TestDownload(unittest.TestCase):
     @classmethod
     def setUpClass(self):
         self.fetched_result = next(arxiv.Search(id_list=["1605.08386"]).results())
+        self.fetched_result_with_slash = next(arxiv.Search(id_list=['hep-ex/0406020v1']).results())
 
     @classmethod
     def setUp(self):
@@ -25,6 +26,12 @@ class TestDownload(unittest.TestCase):
             self.temp_dir,
             '1605.08386v1.Heat_bath_random_walks_with_Markov_bases.pdf')
         ))
+        # Regression-tests https://github.com/lukasschwab/arxiv.py/issues/117.
+        self.fetched_result_with_slash.download_pdf(dirpath=self.temp_dir)
+        self.assertTrue(os.path.exists(os.path.join(
+            self.temp_dir,
+            'hep-ex_0406020v1.Sparticle_Reconstruction_at_LHC.pdf')
+        ))
 
     def test_download_tarfile_from_query(self):
         self.fetched_result.download_source(dirpath=self.temp_dir)