Skip to content

Commit

Permalink
remove anonfiles / bayfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
c-kr committed Aug 17, 2023
1 parent 084f230 commit f199b9b
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 137 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/test-anonfile.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/test-bayfiles.yml

This file was deleted.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Multi Hoster Uploader serves as both a command-line tool and a Python package fo

| Hoster | Status |
|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <img src="https://anonfiles.com/favicon.ico" width="16" height="16" alt="Anonfiles Favicon"> Anonfiles | [![Anonfiles](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-anonfile.yml/badge.svg)](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-anonfile.yml) |
| <img src="https://bayfiles.com/favicon.ico" width="16" height="16" alt="Bayfiles Favicon"> Bayfiles | [![Bayfiles](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-bayfiles.yml/badge.svg)](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-bayfiles.yml) |
| <img src="https://www.file.io/favicon.ico" width="16" height="16" alt="FileIo Favicon"> FileIo | [![FileIO](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-file_io.yml/badge.svg)](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-file_io.yml) |
| <img src="https://gofile.io/dist/img/favicon16.png" width="16" height="16" alt="Gofile Favicon"> GoFile | [![GoFile](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-gofile.yml/badge.svg)](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-gofile.yml) |
| KeepSh | [![KeepSh](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-keepsh.yml/badge.svg)](https://github.com/c-kr/multi_hoster_uploader/actions/workflows/test-keepsh.yml) |
Expand Down Expand Up @@ -64,13 +62,13 @@ To use the `MultiHosterManager` class in your own script, follow these steps:

```python
from hoster import MultiHosterManager
from hoster.hosters import AnonfilesHoster, BayfilesHoster, FileIoHoster, GofileHoster, KeepShHoster
from hoster.hosters import FileIoHoster, GofileHoster, KeepShHoster
```

Instantiate the MultiHosterManager class with the list of hoster classes and, optionally, a flag to randomize the hoster order:

```python
manager = MultiHosterManager([FileIoHoster, GofileHoster, BayfilesHoster, KeepShHoster, AnonfilesHoster], random_hoster=True)
manager = MultiHosterManager([FileIoHoster, GofileHoster, KeepShHoster], random_hoster=True)
```

Call the upload method of the MultiHosterManager instance, providing the file path as an argument:
Expand Down
4 changes: 2 additions & 2 deletions hoster/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from hoster.hosters import AnonfilesHoster, FileIoHoster, BayfilesHoster, GofileHoster
from hoster.base_hoster import Hoster
from random import shuffle
from typing import List, Optional, Type, Union
from pathlib import Path


class MultiHosterManager:
def __init__(self, hosters: List[Type[Hoster]], random_hoster: bool = False):
"""
Expand Down Expand Up @@ -42,4 +42,4 @@ def upload(self, file_path: Union[str, Path]) -> Optional[str]:
except Exception as e:
print(f"An error occurred while uploading to {hoster.__class__.__name__}: {e}")
continue
return None
return None
1 change: 1 addition & 0 deletions hoster/base_hoster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, List, Tuple, Union
from pathlib import Path


class Hoster:
def __init__(self, upload_url: str, upload_url_keys: List[str], success_keys: List[str], success_values: Union[List[Union[str, bool]], None] = None) -> None:
"""
Expand Down
2 changes: 0 additions & 2 deletions hoster/hosters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from .anonfiles import AnonfilesHoster
from .bayfiles import BayfilesHoster
from .file_io import FileIoHoster
from .gofile import GofileHoster
from .keepsh import KeepShHoster
31 changes: 0 additions & 31 deletions hoster/hosters/anonfiles.py

This file was deleted.

29 changes: 0 additions & 29 deletions hoster/hosters/bayfiles.py

This file was deleted.

1 change: 1 addition & 0 deletions hoster/hosters/file_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from hoster.base_hoster import Hoster


class FileIoHoster(Hoster):

def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions hoster/hosters/gofile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from hoster.base_hoster import Hoster
import requests


class GofileHoster(Hoster):
def __init__(self):
super().__init__(
Expand Down
1 change: 1 addition & 0 deletions hoster/hosters/keepsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests
from hoster.base_hoster import Hoster


class KeepShHoster(Hoster):

def __init__(self, bucket_name='free'):
Expand Down
6 changes: 4 additions & 2 deletions multi_hoster_uploader
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ License: MIT

import argparse
from hoster import MultiHosterManager
from hoster.hosters import AnonfilesHoster,BayfilesHoster, FileIoHoster, GofileHoster, KeepShHoster
from hoster.hosters import FileIoHoster, GofileHoster, KeepShHoster
from sys import exit

# define the hoster classes to use in the order to try
HOSTERS = [FileIoHoster, GofileHoster, BayfilesHoster, KeepShHoster, AnonfilesHoster]
HOSTERS = [FileIoHoster, GofileHoster, KeepShHoster]


def main():
parser = argparse.ArgumentParser(description='Upload a file to various file hosting services.')
Expand All @@ -31,5 +32,6 @@ def main():
print('Upload failed.')
exit(2)


if __name__ == '__main__':
main()
12 changes: 3 additions & 9 deletions tests/test_hosters.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import unittest
import os
from hoster.hosters import AnonfilesHoster, BayfilesHoster, FileIoHoster, GofileHoster, KeepShHoster
from hoster.hosters import FileIoHoster, GofileHoster, KeepShHoster


class TestHosters(unittest.TestCase):

def setUp(self):
self.file_path = 'test_file.txt'
self.anonfiles_hoster = AnonfilesHoster()
self.bayfiles_hoster = BayfilesHoster()
self.file_io_hoster = FileIoHoster()
self.gofile_hoster = GofileHoster()
self.keepsh_hoster = KeepShHoster()
Expand All @@ -26,12 +25,6 @@ def _assert_upload(self, hoster):
self.assertIsNotNone(upload_url)
self.assertTrue(upload_url.startswith("https"))

def test_anonfiles_upload(self):
self._assert_upload(self.anonfiles_hoster)

def test_bayfiles_upload(self):
self._assert_upload(self.bayfiles_hoster)

def test_file_io_upload(self):
self._assert_upload(self.file_io_hoster)

Expand All @@ -41,5 +34,6 @@ def test_gofile_upload(self):
def test_keepsh_upload(self):
self._assert_upload(self.keepsh_hoster)


if __name__ == '__main__':
unittest.main()

0 comments on commit f199b9b

Please sign in to comment.