Skip to content

Commit

Permalink
Changed a lot of things to release on PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
pboardman committed Mar 28, 2016
1 parent 5616bf3 commit 17306ed
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 183 deletions.
115 changes: 0 additions & 115 deletions 4scanner.py

This file was deleted.

39 changes: 17 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
Copyright (c) 2016, lacsap-
All rights reserved.
The MIT License (MIT)

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Copyright (c) 2016 lacsap

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
4scanner search 4chan's thread for matching keywords then download all images
to disk

## Requirements
- requests
## Installing

To install all requirements: ``` pip install -r requirement.txt ```
``` pip install 4scanner ```

## How to

Expand All @@ -16,7 +15,7 @@ folder you want, the board(s) you want to search and the keywords.

After your json file is done you can start 4scanner with:

``` 4scanner.py file.json ```
``` 4scanner file.json ```

it will search all threads for the keywords defined in your json file and
download all images/webms from threads where a keyword is found.
Expand Down Expand Up @@ -49,12 +48,11 @@ Here is an example of what the JSON file should look like:
- /f/ - Flash is not supported (yet?)
- the keywords search is case insentitive

## download.py
## 4downloader

download.py is the script used to download the threads found with the keywords.
You can use this this script alone to download a single thread by doing:

``` download.py http://boards.4chan.org/b/thread/373687492 ```
4downloader is also installed with 4scanner and can be use to download
a single thread like this:
``` 4downloader http://boards.4chan.org/b/thread/373687492 ```

It will download all images until the thread die.

Expand Down
43 changes: 43 additions & 0 deletions bin/4downloader
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3

import argparse
import os
import scanner
from scanner import download

def main():
parser = argparse.ArgumentParser()
parser.add_argument('thread', help='url of the thread')
parser.add_argument('folder', nargs='?',
help='Change the folder name where images are downloaded')
parser.add_argument("-q", "--quiet", action='store_true', help="quiet")
parser.add_argument("-o", "--output", help="Specify output folder")
args = parser.parse_args()

print(args.thread)

quiet = False
if args.quiet:
quiet = True

if args.folder is not None:
folder = ''.join(args.folder)
else:
folder = ''.join(args.thread).split('/')[5].split('#')[0]

if args.output is not None:
output = args.output
if not os.path.exists(output):
print("{0} Does not exist.".format(output))
exit(1)
else:
output = os.getcwd()

download.download_thread(args.thread, output, folder, quiet)


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
40 changes: 40 additions & 0 deletions bin/4scanner
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import argparse
import os
import scanner
from scanner import scanner
import time


def main():
# Arguments parsing and validation
parser = argparse.ArgumentParser()
parser.add_argument("keywords_file",
help="file with the keywords to search for")
parser.add_argument("-o", "--output", help="Specify output folder")
args = parser.parse_args()

# Checking keywords file
if not os.path.isfile(args.keywords_file):
print("Keywords file does not exist...")
exit(1)

if args.output:
output = args.output
if not os.path.exists(output):
print("{0} Does not exist.".format(output))
exit(1)
else:
output = os.getcwd()

log_file = "downloaded-{0}.txt".format(time.strftime('%d%m%Y_%H%M'))

scanner.scan(args.keywords_file, output, log_file)


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
Empty file added scanner/__init__.py
Empty file.
37 changes: 0 additions & 37 deletions download.py → scanner/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,6 @@
import requests


def main():
parser = argparse.ArgumentParser()
parser.add_argument('thread', help='url of the thread')
parser.add_argument('folder', nargs='?',
help='Change the folder name where images are downloaded')
parser.add_argument("-q", "--quiet", action='store_true', help="quiet")
parser.add_argument("-o", "--output", help="Specify output folder")
args = parser.parse_args()

print(args.thread)

quiet = False
if args.quiet:
quiet = True

if args.folder is not None:
folder = ''.join(args.folder)
else:
folder = ''.join(args.thread).split('/')[5].split('#')[0]

if args.output is not None:
output = args.output
if not os.path.exists(output):
print("{0} Does not exist.".format(output))
exit(1)
else:
output = os.path.dirname(os.path.realpath(__file__))

download_thread(args.thread, output, folder, quiet)


def load(url):
response = requests.get(url)
response.raise_for_status()
Expand Down Expand Up @@ -68,9 +37,3 @@ def download_thread(thread, output_folder, folder, is_quiet):
if not is_quiet:
print('thread 404\'d')
exit(0)

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
Loading

0 comments on commit 17306ed

Please sign in to comment.