diff --git a/setup.py b/setup.py index e69de29..d2059f8 100644 --- a/setup.py +++ b/setup.py @@ -0,0 +1,26 @@ +from importlib.metadata import entry_points +import setuptools + + + +with open('README.md', 'r') as readme: + long_description = readme.read() + + + +setuptools.setup( + name='yoink', + version='0.2.0', + author='Bryan Bailey', + author_email='brizzledev@gmail.com', + description='', + long_description=long_description, + long_description_content_type='text/markdown', + url='https://gitlab.com/Rigil-Kent/yoink', + entry_points={ + 'console_scripts': [ + 'yoink = yoink.cli:yoink' + ] + }, + install_requires=['click', 'bs4', 'requests'] +) \ No newline at end of file diff --git a/yoink/cli.py b/yoink/cli.py index bc43b4e..dcb6277 100644 --- a/yoink/cli.py +++ b/yoink/cli.py @@ -1,18 +1,30 @@ +import os +import sys import click -import libtorrent as lib from yoink.common import app_root, library_path, config_path from yoink.comic import Comic -from yoink.torrent import Torrent, downloader -session = lib.session() -session.listen_on(6881, 6891) + queue = [] @click.group() -def yoink(): - pass +@click.option('-c', '--comic', help='Download a Comic file') +@click.option('-t', '--torrent', help='Download a Torrent') +def yoink(comic, torrent): + if comic: + click.echo('Downloading a comic') + + if torrent: + click.echo('Downloading a torrent') + + + +@yoink.command() +def init(): + + click.echo(f'Initializing for {sys.platform}') @yoink.command() @@ -32,21 +44,6 @@ def download(url): # comic.archiver.cleanup_worktree() # click.echo('Success') - torrent = Torrent(url) - print(torrent.magnet_link) - - # queue.append(lib.add_magnet_uri(session, torrent.magnet_link, {'save_path': library_path})) - - # while queue: - # next_shift = 0 - - # for index, download in enumerate(queue): - # if not download.is_seed(): - # status = download.status() - - - # downloader.add(torrent) - # downloader.download() if __name__=='__main__': yoink() \ No newline at end of file diff --git a/yoink/torrent.py b/yoink/torrent.py index abf8107..6ad05ab 100644 --- a/yoink/torrent.py +++ b/yoink/torrent.py @@ -1,5 +1,4 @@ from bs4 import BeautifulSoup -from qbittorrent import Client import requests import os @@ -26,9 +25,9 @@ class TorrentDownloader: def create_torrent(cls, url): return Torrent(url) - @classmethod - def get_torrent(cls, name): - return [torrent for torrent in new_downloader.torrents() if name == torrent['name']][0] + # @classmethod + # def get_torrent(cls, name): + # return [torrent for torrent in new_downloader.torrents() if name == torrent['name']][0] @classmethod def quick_download(cls, url): @@ -40,8 +39,7 @@ class TorrentDownloader: soup = BeautifulSoup(markup, 'html.parser') magnet_link = soup.find('a', attrs={'title': 'Get this torrent'}.attrs['href']) - # qb_client.download_from_link(url if url.startswith('magnet') else magnet_link) - new_downloader.torrents.add(urls=url if url.startswith('magnet') else magnet_link) + def set_path(self, path): @@ -68,10 +66,8 @@ class TorrentDownloader: if not isinstance(torrent, Torrent): raise TypeError('Not a valid torrent') - # qb_client.download_from_link(torrent.magnet_link) print(torrent.magnet_link) - # qb_client2.torrents.add(urls=torrent.magnet_link) - # print(new_downloader.torrents()) + downloader = TorrentDownloader()