JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 22.03.2013, 13:46
danutz
Guest
 
Posts: n/a
Default 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.
Attached Files
File Type: zip csv2jd.zip (566 Bytes, 141 views)

Last edited by danutz; 22.03.2013 at 14:10. Reason: clarify
Reply With Quote
  #2  
Old 21.08.2017, 16:35
PukinG
Guest
 
Posts: n/a
Default

I can't access the file
Reply With Quote
  #3  
Old 21.08.2017, 17:07
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,343
Default

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
Reply With Quote
  #4  
Old 20.01.2018, 03:29
Program
Guest
 
Posts: n/a
Default Dubt about using this script

Quote:
Originally Posted by Jiaz View Post
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)

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
Reply With Quote
  #5  
Old 22.01.2018, 18:00
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,343
Default

@Program: This is a python script for unix systems.
I will answer in your other thread
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 13:08.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.