Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
__pycache__/
*.py[cod]
*$py.class
.vscode/

test*
note.txt

# C extensions
*.so
Expand Down
69 changes: 37 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
A python module to download and upload from [gigafile](https://gigafile.nu/).
This is a personal tool as you may come across errors and bugs so feel free to add an issue.

# Install

$ python setup.py install --user
or
$ pip install git+https://github.com/Sraq-Zit/gfile.git
or

# Usage
$ pip install git+https://github.com/Sraq-Zit/gfile.git -U

# Usage
## Module
### Import
from gfile import GFile
```py
from gfile import GFile
```
### Download
url, cookies = GFile('https://XX.gigafile.nu/YYY').get_download()
# or
filename = GFile('https://XX.gigafile.nu/YYY').download()
```py
filename = GFile('https://XX.gigafile.nu/YYY').download()
```

### Upload
url = GFile('path/to/file', progress=True).upload().get_download_page()
```py
url = GFile('path/to/file', progress=True).upload().get_download_page()
```

## CLI

$ gfile upload path/to/file

$ gfile download https://66.gigafile.nu/0320-b36ec21d4a56b143537e12df7388a5367

$ gfile -h
usage: Gfile [-h] [-p] [-n THREAD_NUM] [-s CHUNK_SIZE] [-m CHUNK_COPY_SIZE] {download,upload} uri

positional arguments:
{download,upload} Upload or download
uri Filename to upload or url to download

optional arguments:
-h, --help show this help message and exit
-p, --hide-progress Hide progress bar
-n THREAD_NUM, --thread-num THREAD_NUM
Number of threads used for upload (can incease speed)
-s CHUNK_SIZE, --chunk-size CHUNK_SIZE
allowed chunk size per upload
-m CHUNK_COPY_SIZE, --copy-size CHUNK_COPY_SIZE
Specifies size to copy the main file into pieces (the size loaded in RAM)

```bash
$ gfile upload path/to/file

$ gfile download https://66.gigafile.nu/0320-b36ec21d4a56b143537e12df7388a5367

$ gfile -h
usage: Gfile [-h] [-p] [-o OUTPUT] [-n THREAD_NUM] [-s CHUNK_SIZE] [-m CHUNK_COPY_SIZE] {download,upload} uri

positional arguments:
{download,upload} upload or download
uri filename to upload or url to download

options:
-h, --help show this help message and exit
-p, --hide-progress hide progress bar
-o OUTPUT, --output OUTPUT
output filename for download
-n THREAD_NUM, --thread-num THREAD_NUM
number of threads used for upload [default: 8]
-s CHUNK_SIZE, --chunk-size CHUNK_SIZE
chunk size per upload in bytes; note: chunk_size*thread will be loaded into memory [default: 100MB]
-m CHUNK_COPY_SIZE, --copy-size CHUNK_COPY_SIZE
specifies size to copy the main file into pieces [default: 1MB]
```
5 changes: 2 additions & 3 deletions gfile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .gfile import GFile

__author__ = """SraqZit"""
__email__ = 'sraqzit@gmail.com'
__version__ = '2.1'
__author__ = """Sraqzit, fireattack"""
__version__ = '3.1'
4 changes: 4 additions & 0 deletions gfile/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import cmd

if __name__ == '__main__':
cmd.main()
20 changes: 8 additions & 12 deletions gfile/cmd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

import argparse
from enum import Enum
import re

from tqdm import tqdm
if __name__ == "__main__": from gfile import GFile
else: from .gfile import GFile

Expand All @@ -12,27 +10,25 @@ class Action(Enum):
upload = 'upload'
def __str__(self):
return self.value



def main():
parser = argparse.ArgumentParser(prog='Gfile')
parser.add_argument('action', type=Action, choices=list(Action), help='upload or download')
parser.add_argument('uri', help='filename to upload or url to download')
parser.add_argument('-p', '--hide-progress', dest='progress', action='store_false', default=True, help='hide progress bar')
parser.add_argument('-o', '--output', dest='output file', type=str, default=None, help='hide progress bar')
parser.add_argument('-n', '--thread-num', dest='thread_num', default=int(4), type=int, help='number of threads used for upload (can incease speed)')
parser.add_argument('-s', '--chunk-size', dest='chunk_size', type=int, help='gigafile allowed chunk size per upload', default=1024*1024*100)
parser.add_argument('-m', '--copy-size', dest='chunk_copy_size', type=int, help='specifies size to copy the main file into pieces (the size loaded in RAM)', default=1024*1024)
parser.add_argument('-o', '--output', type=str, default=None, help='output filename for download')
parser.add_argument('-n', '--thread-num', dest='thread_num', default=8, type=int, help='number of threads used for upload [default: 8]')
parser.add_argument('-s', '--chunk-size', dest='chunk_size', default="100MB", help='chunk size per upload in bytes; note: chunk_size*thread will be loaded into memory [default: 100MB]')
parser.add_argument('-m', '--copy-size', dest='chunk_copy_size', default="1MB", help='specifies size to copy the main file into pieces [default: 1MB]')
parser.add_argument('-t', '--timeout', type=int, default=10, help='specifies timeout time (in seconds) [default: 10]')

args = parser.parse_args()

gf = GFile(**args.__dict__)
if args.action == Action.download:
gf.download(args.chunk_copy_size, args.progress)

gf.download(args.output)
else:
print(gf.upload().get_download_page())
gf.upload().get_download_page()

if __name__ == "__main__":
main()
Loading