#1
|
|||
|
|||
Contrib: add links w/ package names from a CSV spreadsheet into JD2
Simple script to add links into JD2 from a CSV file (spreadsheet) containing "title" and "urls" columns (other columns in the CSV are ignored). The urls column must contain download links separated by spaces. The "title" colum will be used for package names.
Make sure to set minimum number of links per package to 0 (i.e. disabled) in advanced options, otherwise you will get the dreaded "Various Files" packages for the rows which contain a single link. Should be cross platform, it's a single Python script using no special extensions. Last edited by danutz; 22.03.2013 at 14:10. Reason: clarify |
#2
|
|||
|
|||
I can't access the file
|
#3
|
||||
|
||||
Code:
#!/usr/bin/env python import csv import sys import urllib2 import json csvin = csv.DictReader (sys.stdin) csvout = csv.DictWriter (sys.stdout, csvin.fieldnames + ["jderr"]) emptyout = True for l in csvin: links = l ["urls"] pkg = l ["title"] links = links.replace (" ", "%20") pkg = pkg.replace ('"', "'").replace ("&", " ").replace (" ", "%20") url = "**External links are only visible to Support Staff**.format (links, pkg, '""', '""') result = urllib2.urlopen (url) resp = None if result.getcode () == 200: resp = json.load (result) if not resp or resp.get ("data") != True: l ["jderr"] = json.dumps (resp) if emptyout: emptyout = False; csvout.writeheader () csvout.writerow (l)
__________________
JD-Dev & Server-Admin |
#4
|
|||
|
|||
Dubt about using this script
Quote:
Dear, Sorry, i'm new in Jdwonloader, i dont find a tutorial teaching how to put a script. I cant download, so i try put this script in create script event, and paste the script, so appear to me: "Illegal character (#1)" If the exclude this row: "#!/usr/bin/env python", appear: "missing ; before statement (#1)" Where i must put this script? thanks in advanced Last edited by Program; 20.01.2018 at 03:37. Reason: more info |
#5
|
||||
|
||||
@Program: This is a python script for unix systems.
I will answer in your other thread
__________________
JD-Dev & Server-Admin |
Thread Tools | |
Display Modes | |
|
|