packages: pynapi/pynapi.py, pynapi/pynapi.spec - rel 13; download covers, too
arekm
arekm at pld-linux.org
Wed Feb 3 23:25:01 CET 2010
Author: arekm Date: Wed Feb 3 22:25:01 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- rel 13; download covers, too
---- Files affected:
packages/pynapi:
pynapi.py (1.32 -> 1.33) , pynapi.spec (1.15 -> 1.16)
---- Diffs:
================================================================
Index: packages/pynapi/pynapi.py
diff -u packages/pynapi/pynapi.py:1.32 packages/pynapi/pynapi.py:1.33
--- packages/pynapi/pynapi.py:1.32 Wed Nov 11 20:23:51 2009
+++ packages/pynapi/pynapi.py Wed Feb 3 23:24:55 2010
@@ -20,11 +20,11 @@
import re
import sys
-import urllib
+import mimetypes
+import urllib2
import subprocess
import tempfile
import time
-import urllib
import os
import getopt
@@ -64,7 +64,7 @@
print >> sys.stderr, "Supported options:"
print >> sys.stderr, " -h, --help display this help and exit"
print >> sys.stderr, " -l, --lang=LANG subtitles language"
- print >> sys.stderr, " -n, --nobackup make no backup when in update mode"
+ print >> sys.stderr, " -n, --nobackup make no subtitle backup when in update mode"
print >> sys.stderr, " -u, --update fetch new and also update existing subtitles"
print >> sys.stderr, " -d, --dest=DIR destination directory"
print >> sys.stderr
@@ -78,14 +78,26 @@
d = ""
try:
- url = "http://www.napiprojekt.pl/index.php3?www=opis.php3&id=%s&film=%s" % (urllib.quote(digest), urllib.quote(file))
- f = urllib.urlopen(url)
+ url = "http://www.napiprojekt.pl/index.php3?www=opis.php3&id=%s&film=%s" % (urllib2.quote(digest), urllib2.quote(file))
+ f = urllib2.urlopen(url)
d = f.read()
f.close()
except Exception, e:
return False
return re_link.findall(d)
+def get_cover(digest):
+ cover = ""
+ try:
+ url = "http://www.napiprojekt.pl/okladka_pobierz.php?id=%s&oceny=-1" % (urllib2.quote(digest))
+ f = urllib2.urlopen(url)
+ cover = f.read()
+ f.close()
+ content_type = f.info()['Content-Type']
+ extension = mimetypes.guess_all_extensions(content_type)[-1]
+ except Exception, e:
+ return False
+ return (cover, extension)
def main(argv=sys.argv):
@@ -149,8 +161,10 @@
i += 1
vfile = file + '.txt'
+ basefile = file
if len(file) > 4:
- vfile = file[:-4] + '.txt'
+ basefile = file[:-4]
+ vfile = basefile + '.txt'
if dest:
vfile = os.path.join(dest, os.path.split(vfile)[1])
@@ -185,7 +199,7 @@
while repeat > 0:
repeat = repeat - 1
try:
- sub = urllib.urlopen(url)
+ sub = urllib2.urlopen(url)
if hasattr(sub, 'getcode'):
http_code = sub.getcode()
sub = sub.read()
@@ -243,7 +257,16 @@
for desc_i in desc:
print >> sys.stderr, "\t\t%s" % desc_i
- print >> sys.stderr, "%s: %d/%d: STORED (%d bytes)" % (prog, i, i_total, len(so))
+ cover_stored = ""
+ cover_data = get_cover(d.hexdigest())
+ if cover_data:
+ cover, extension = cover_data
+ fp = open(basefile + extension, 'w')
+ fp.write(cover)
+ fp.close()
+ cover_stored = ", %s COVER STORED (%d bytes)" % (extension, len(cover))
+
+ print >> sys.stderr, "%s: %d/%d: SUBTITLE STORED (%d bytes)%s" % (prog, i, i_total, len(so), cover_stored)
return 0
================================================================
Index: packages/pynapi/pynapi.spec
diff -u packages/pynapi/pynapi.spec:1.15 packages/pynapi/pynapi.spec:1.16
--- packages/pynapi/pynapi.spec:1.15 Sun Sep 27 10:58:53 2009
+++ packages/pynapi/pynapi.spec Wed Feb 3 23:24:55 2010
@@ -2,7 +2,7 @@
Summary: pynapi - Movie Subtitle Downloader
Summary(pl.UTF-8): pynapi - narzędzie do ściągania napisów do filmów
Name: pynapi
-Version: 0.12
+Version: 0.13
Release: 1
License: GPL v3+
Group: Applications/Multimedia
@@ -43,6 +43,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.16 2010/02/03 22:24:55 arekm
+- rel 13; download covers, too
+
Revision 1.15 2009/09/27 08:58:53 arekm
rel 0.12; nicer display for descriptions
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/pynapi/pynapi.py?r1=1.32&r2=1.33&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/pynapi/pynapi.spec?r1=1.15&r2=1.16&f=u
More information about the pld-cvs-commit
mailing list