[SCM] hydrogen-drumkits/master: option to fix known-to-be-bad URLs

umlaeute at users.alioth.debian.org umlaeute at users.alioth.debian.org
Thu Sep 24 08:58:28 UTC 2015


The following commit has been merged in the master branch:
commit c0d4bdf90d62ef4a9a3e8e882e2a93ae6d746ddd
Author: IOhannes m zmölnig <zmoelnig at iem.at>
Date:   Thu Sep 24 10:33:13 2015 +0200

    option to fix known-to-be-bad URLs
    
    e.g. the feed reports downloads from "http://switch.dl.sourceforge.net",
    which no longer exists.

diff --git a/debian/get-orig-source.py b/debian/get-orig-source.py
index 3478bad..8da4f15 100755
--- a/debian/get-orig-source.py
+++ b/debian/get-orig-source.py
@@ -80,6 +80,10 @@ URL = 'http://www.hydrogen-music.org/feeds/drumkit_list.php'
 #OUTFILE='hydrogen-drumkits.tar.gz'
 OUTFILE=None
 
+## apply replacements on URLs
+URLFIX=[]
+URLFIX+=[("http://switch.dl.sourceforge.net/sourceforge/", "http://downloads.sourceforge.net/project/")]
+
 ### come compat foo
 
 # use html2text if available
@@ -182,6 +186,11 @@ def copyUnsetNonempty(src, dst):
         if src[key] != '':
             dst[key]=src[key]
 
+def fixURL(url, replacements):
+    for (src, dst) in replacements:
+        url=url.replace(src, dst)
+    return url
+
 def download(url, outputfile=None):
     """
     download url into outputfile;
@@ -304,12 +313,14 @@ def guessFilenameFromURL(url):
     url=stripSuffix(url, '.h2drumkit/download', '/download')
     return os.path.basename(url)
 
-def downloadPkgs(pkgs, path):
+def downloadPkgs(pkgs, path, urlfixes=None):
     makedir(path)
     count=0
     for pkg in pkgs:
         count=count+1
         url=pkg['url']
+        if urlfixes:
+            url=fixURL(url, urlfixes)
         fname=pkg['filename']
         print("downloading %s into %s [%d/%d]" % (url, fname, count, len(pkgs)))
         download(url, os.path.join(path, fname))
@@ -412,7 +423,14 @@ def pkg_drumkits(conf):
         except EOFError:
             download=False
     if download:
-        downloadPkgs(pkgs, os.path.join(conf.workdir, 'drumkits'))
+        if conf.no_url_fixes:
+            urlfix=None
+            print("NOT applying the following URL-fixes:")
+            for (a,b) in URLFIX:
+                print(" '%s' -> '%s'" % (a,b))
+        else:
+            urlfix=URLFIX
+        downloadPkgs(pkgs, os.path.join(conf.workdir, 'drumkits'), urlfix)
     return pkgs
 
 def main(conf):
@@ -446,6 +464,8 @@ def parseCmdlineArgs():
     parser.add_argument('-x', '--non-interactive', action='store_true',
                         help="don't ask interactive questions (re-create a tarball from all pre-approved items)"
                         )
+    parser.add_argument('--no-url-fixes', action='store_true',
+                        help="don't attempt to fix known-to-be-broken URLs")
     parser.add_argument('--add-all-regardless-of-license', action='store_true',
                         help="DO NOT USE THIS FOR CREATING A TARBALL FOR DEBIAN PACKAGING")
     args = parser.parse_args()

-- 
hydrogen-drumkits packaging



More information about the pkg-multimedia-commits mailing list