Fix for NNM Club domain change
This commit is contained in:
parent
d391c3ddea
commit
1871418e8b
25
massdl.py
25
massdl.py
@ -1,6 +1,7 @@
|
|||||||
|
#!/usr/bin/env python2.7
|
||||||
# *-* encoding: utf-8 *-*
|
# *-* encoding: utf-8 *-*
|
||||||
# For NNM-Club Uploaders
|
# For NNM-Club Uploaders
|
||||||
# Copyright (c) 2012-2014 Valdos Sine <iam@toofat.ru>
|
# Copyright (c) 2012-2016 Vladimir Kozlov <iam@toofat.ru>
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
@ -13,10 +14,10 @@ import lib.config as uconfig
|
|||||||
import lib.messages as umessages
|
import lib.messages as umessages
|
||||||
import dateutil
|
import dateutil
|
||||||
from dateutil.parser import *
|
from dateutil.parser import *
|
||||||
version = 0.80
|
version = 0.92
|
||||||
unixtime = int(time.time())
|
unixtime = int(time.time())
|
||||||
cookie = tempfile.mkstemp()
|
cookie = tempfile.mkstemp()
|
||||||
curdir = os.getcwd()
|
curdir = uconfig.workdir
|
||||||
log_file = "/%i-massdl.log" % unixtime
|
log_file = "/%i-massdl.log" % unixtime
|
||||||
domain = uconfig.domain
|
domain = uconfig.domain
|
||||||
|
|
||||||
@ -170,7 +171,8 @@ def download():
|
|||||||
cnsl_message("found_topics", str(len(topics)))
|
cnsl_message("found_topics", str(len(topics)))
|
||||||
# Aaaand... the first real actions is here
|
# Aaaand... the first real actions is here
|
||||||
torrentsdir = "%s/%s" % (curdir, sys.argv[1])
|
torrentsdir = "%s/%s" % (curdir, sys.argv[1])
|
||||||
os.mkdir(torrentsdir)
|
if not os.path.exists(torrentsdir):
|
||||||
|
os.makedirs(torrentsdir)
|
||||||
get_torrent(topics, torrentsdir, forumname)
|
get_torrent(topics, torrentsdir, forumname)
|
||||||
|
|
||||||
def parse_topic(topic, forumname, topics, torrents_count, torrentsdir):
|
def parse_topic(topic, forumname, topics, torrents_count, torrentsdir):
|
||||||
@ -186,6 +188,11 @@ def parse_topic(topic, forumname, topics, torrents_count, torrentsdir):
|
|||||||
for line in topicpage.splitlines():
|
for line in topicpage.splitlines():
|
||||||
if 'проверено модератором' in line:
|
if 'проверено модератором' in line:
|
||||||
tdate_raw = line
|
tdate_raw = line
|
||||||
|
try:
|
||||||
|
tdate_raw
|
||||||
|
except NameError:
|
||||||
|
cnsl_message("skip_non_approved", str(torrents_count), str(len(topics)), topicname, (domain + "/" + topic))
|
||||||
|
return 340
|
||||||
# fix for russian months names (dateutil doesn't parse it, damnnt)
|
# fix for russian months names (dateutil doesn't parse it, damnnt)
|
||||||
tdate_raw = tdate_raw.replace('Янв', '01').replace('Фев', '02').replace('Мар', '03').replace('Апр', '04').replace('Май', '05').replace('Июн', '06').replace('Июл', '07').replace('Авг', '08').replace('Сен', '09').replace('Окт', '10').replace('Ноя', '11').replace('Дек', '12')
|
tdate_raw = tdate_raw.replace('Янв', '01').replace('Фев', '02').replace('Мар', '03').replace('Апр', '04').replace('Май', '05').replace('Июн', '06').replace('Июл', '07').replace('Авг', '08').replace('Сен', '09').replace('Окт', '10').replace('Ноя', '11').replace('Дек', '12')
|
||||||
topicdate = dateutil.parser.parse(tdate_raw.split('>')[1].split('<')[0].split(' ',3)[3]).strftime("%Y-%m-%d")
|
topicdate = dateutil.parser.parse(tdate_raw.split('>')[1].split('<')[0].split(' ',3)[3]).strftime("%Y-%m-%d")
|
||||||
@ -197,13 +204,11 @@ def parse_topic(topic, forumname, topics, torrents_count, torrentsdir):
|
|||||||
downlink = dl_raw.split('"')[1]
|
downlink = dl_raw.split('"')[1]
|
||||||
cnsl_message("downloading_torrent", str(torrents_count), str(len(topics)), topicname, (domain + "/" + topic), topicdate)
|
cnsl_message("downloading_torrent", str(torrents_count), str(len(topics)), topicname, (domain + "/" + topic), topicdate)
|
||||||
os.chdir(torrentsdir)
|
os.chdir(torrentsdir)
|
||||||
if not os.path.exists("./%s" % topicdate):
|
download_torrent(downlink, topicdate)
|
||||||
os.makedirs("./%s" % topicdate)
|
|
||||||
os.chdir("./%s" % topicdate)
|
|
||||||
download_torrent(downlink)
|
|
||||||
|
|
||||||
def download_torrent(downlink):
|
def download_torrent(downlink, topicdate):
|
||||||
os.system('curl -b ' + cookie[1] + ' -O -J -L "' + domain + '/forum/' + downlink + '" 2>>' + curdir + log_file)
|
basefilename = commands.getoutput('curl -sI -b ' + cookie[1] + ' -J -L "' + domain + '/forum/' + downlink + '"' + "| grep -o -E 'filename=.*$' | tr -d '\r\n' | sed -e 's/filename=//' | sed 's/\"//g'")
|
||||||
|
os.system('curl -b %s -L "%s/forum/%s" -o "%s %s" 2>> %s%s' % (cookie[1], domain, downlink, topicdate, basefilename, curdir, log_file))
|
||||||
|
|
||||||
def get_torrent(topics, torrentsdir, forumname):
|
def get_torrent(topics, torrentsdir, forumname):
|
||||||
cnsl_message("download_started")
|
cnsl_message("download_started")
|
||||||
|
Loading…
Reference in New Issue
Block a user