Skip to content

Commit

Permalink
add downloader for tv serials
Browse files Browse the repository at this point in the history
  • Loading branch information
CCharlieLi committed May 14, 2016
1 parent fb65455 commit 1e2aa79
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 29 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,34 @@ Funny tools for downloading movies, tv serials and BLEACH comics
- Automatically download latest comics BLEACH from __BLEACH__ __Baidu__ __Tieba__.
- Comics will be saved in __BLEACH/[Name]__ in current directory.
- No comics will be downloaded twice according to existence of __BLEACH/[Name]__.
- Automatically download TV serials from 人人影视 with given ID.

## Requirement

__Python 3__

## Usage

- Command line

```
pip install funny_tool
pip3 install funny_tool
```

```
usage: ft [-h] [-b] [-d] [-p PAGE]
usage: ft [-h] [-b] [-d] [-p PAGE] [-t TV] [-l]
funny_tool: Download movies, tv serials and comics!
optional arguments:
-h, --help show this help message and exit
-b, --bleach Download BLEACH.
-d, --dytt Download latest movies from dytt.
-p PAGE, --page PAGE pages to retrieve when downloading movies from dytt,
should be used with -d.
-s, --shield Download Marvels.Agents.of.S.H.I.E.L.D.
-t TV, --tv TV Download TV serials by giving ID, use flag -l to check
IDs.
-l, --list TV serials list.
```

- Python lib
Expand All @@ -36,8 +45,9 @@ import funny_tool
funny_tool.bleach()
funny_tool.dytt()
funny_tool.dytt(2)
funny_tool.shield()
funny_tool.dytt(2) # retrieve 2 pages
funny_tool.tv(30675) # Shield
funny_tool.tvlist()
```

## TODO
Expand Down
13 changes: 9 additions & 4 deletions funny_tool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .bleach import BLEACH
from .dytt import DYTT
from .shield import SHIELD
from .tvserials import TVSerials
from .utils.TVList import get_list

def bleach():
b = BLEACH()
Expand All @@ -10,6 +11,10 @@ def dytt(page = 1):
d = DYTT()
d.get_Latest_URLs(page)

def shield():
s = SHIELD()
s.get_serials()
# id: String
def tv(id):
s = TVSerials()
s.get_serials(id)

def tvlist():
return get_list()
27 changes: 17 additions & 10 deletions funny_tool/funny_tool.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from .bleach import BLEACH
from .dytt import DYTT
from .shield import SHIELD
import argparse
from .tvserials import TVSerials
import os, argparse

def all():
parser = argparse.ArgumentParser(description = 'funny_tool: Download movies, tv serials and comics!')
parser.add_argument('-b', '--bleach', action='store_true', help='Download BLEACH.')
parser.add_argument('-d', '--dytt', action='store_true', help='Download latest movies from dytt.')
parser.add_argument('-p', '--page', action='store', type=int, default=1,
help='pages to retrieve when downloading movies from dytt, should be used with -d.')
parser.add_argument('-s', '--shield', action='store_true', help='Download Marvels.Agents.of.S.H.I.E.L.D.')
parser.add_argument('-t', '--tv', action='store', type=str, help='Download TV serials by giving ID, use flag -l to check IDs.')
parser.add_argument('-l', '--list', action='store_true', help='TV serials list.')
given_args = parser.parse_args()


print('''
,----,
,/ .`|
Expand All @@ -34,14 +36,19 @@ def all():
if given_args.bleach:
b = BLEACH()
b.get_Latest_URLs()

if given_args.dytt:
t = DYTT()
t.get_Latest_URLs(given_args.page)

if given_args.shield:
s = SHIELD()
s.get_serials()

if given_args.bleach == False and given_args.dytt == False and given_args.shield == False:

if given_args.tv:
s = TVSerials()
s.get_serials(given_args.tv)

if given_args.list:
from .utils.TVList import get_list
tvlist = get_list()
for key in tvlist.keys(): print(key + ' ' + tvlist[key])

if not given_args.bleach and not given_args.dytt and not given_args.tv and not given_args.list:
parser.print_help()
24 changes: 16 additions & 8 deletions funny_tool/shield.py → funny_tool/tvserials.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from bs4 import BeautifulSoup
from tqdm import tqdm
from .utils.rrys_login import RRYS_Login
import os, time
from .utils.TVList import get_list
import os, time, re

class SHIELD(object):
class TVSerials(object):

def __init__(self):
self.prefix = 'http://www.zimuzu.tv/'
self.type = 'HR-HDTV'
self.logfile = 'SHIELD.txt'
self.link = ['迅雷'] # '电驴','网盘','城通'
self.path = os.getcwd() + '/' + self.logfile

'''
Calculate shows to download
Expand All @@ -24,15 +23,24 @@ def calculate(self, list, last = 'S00E00'):
return latest_index - last_index

'''
Extract 'S.H.I.E.L.D.' TOTD: should replace with regex.
Extract S??E??
'''
def extract_string(self, string):
return string[string.find("S.H.I.E.L.D.") + 12: string.find("S.H.I.E.L.D.") + 18]
return re.search('(S\d{2}E\d{2})\.', string).groups()[0]

'''
Get info from tv play list
'''
def get_serials(self, sersials_id = '30675'):
def get_serials(self, sersials_id):
tvlist = get_list()
if sersials_id not in tvlist.keys():
print('No TV serials for such a id.')
return

self.logfile = tvlist[sersials_id] + '.txt'
self.path = os.getcwd() + '/' + self.logfile
print('TV : Starting to download ' + tvlist[sersials_id])

# Get last num
log = open(self.path, 'a+')
log.seek(0)
Expand Down Expand Up @@ -74,4 +82,4 @@ def get_serials(self, sersials_id = '30675'):
log.close()
# Close bar
progress_bar.close()
print('SHIELD: Download finished! ' + str(count) + ' tv serials downloaded. Check SHIELD.txt.')
print('TV : Download finished! ' + str(count) + ' tv serials downloaded. Check ' + self.logfile)
5 changes: 5 additions & 0 deletions funny_tool/utils/TVList.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def get_list():
return {
'30675': 'S.H.I.E.L.D',
'31801': 'Silicon Valley'
}
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
except ImportError:
from distutils.core import setup

README = ''
with open('README.md', mode='r', encoding='utf-8') as rdm:
README = rdm.read()

setup(
name='funny_tool',
version='0.2.3',
version='0.2.5',
description='The funny tools to download movies and comics',
long_description=README,
author='CCharlieLi',
author_email='[email protected]',
url='https://github.com/CCharlieLi/funny_tool',
Expand All @@ -30,7 +35,6 @@
'Environment :: Console',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
Expand Down
Binary file modified usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1e2aa79

Please sign in to comment.