User talk:Nichalp/Upload script

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Pending tasks for Nichalp/Upload script: edit this list - add to watchlist - purge
  • Rewrite for PNG, SVG, OGG, PDF and GIF.
  • Combine for all
  • Mask password

Customisation[edit]

Many of the fields are unnecessary to most users. For example, I generally geocode in decimal degrees, and my images are referenced to N and E. Similarly I release my images under one licence. Hence, you can customise the scripts to automatically encode this. A little bit of Perl coding is necessary. Nichalp (talk) 07:49, 6 September 2008 (UTC)[reply]


About non-JPEG's[edit]

Is it possible to use this script to batch upload images, with the descriptions set as you do, without modifying the images, if the images are not jpeg's? Specifically, I have a large number of PNG's that I'd like to upload, along with similar descriptions for each one. No need to modify the file itself. Is that available? --DragoonWraith (talk) 19:27, 1 November 2008 (UTC)[reply]

Yes, it can be done, 2-3 lines of the code need to be changed. . Sorry, this page had got off my watchlist for no reason, therefore the delay. :( Give me a two days to respond. Nichalp (talk) 12:50, 9 November 2008 (UTC)[reply]
  1. In User:Nichalp/Upload script/csv creator.pl change
    @files = grep (/\.jpe?g$/i, readdir(DIR));
    • to
    @files = grep (/\.png$/i, readdir(DIR));
  2. In User:Nichalp/Upload script/upload.pl change
    $new_name .= ".jpg" unless $new_name =~ /\.jpe?g$/i; # adding JPG extn
    • to
    $new_name .= ".png" unless $new_name =~ /\.png$/i; # adding PNG extn
  3. Make sure that you add the categories, description, licence and date. That is needed. Rest you can leave blank.
  4. The date field will be blank (no EXIF values to pick up of course), so you would have to ensure that you add the date manually. If you have just one date to add, you could program the $date=(set the date) into the code:
  5. Before this line: $ignore_login_error=0; add $date="2008-11-09"; (PS Change the date to the current date you upload!)

Nichalp (talk) 13:06, 9 November 2008 (UTC)[reply]

You're sorry about the delay, I'm coming back more than two years later! I can't honestly remember what I'd wanted to upload (actually, I have a guess; if correct, that Wiki no longer exists). Sorry about that; I don't use Wikimedia Commons often (obviously!). I do appreciate you getting back to me on that, though. Just wanted to let you know, that even after all this time, I did see this.
DragoonWraith (talk) 05:02, 29 January 2011 (UTC)[reply]

Problems[edit]

I wasn't able to archive my goal with this script:

  • There seems to be problems with character sets. German Umlauts (ü) could be read from file names into CSV, but upload.pl couldn't find the files again
  • Licence type 0 was not reconized as valid (bug in upload.pl I think: permission_value > 0 should have been permission_value => 0)
  • Log on to Commons failed with the comment "You are trying to hack this script for other wikis". I changed the suggested value in the source, but finally I gave up altogether.

Nillerdk (talk) 01:17, 21 January 2009 (UTC)[reply]

Should be fixed now! Try version 1.2 of upload.pl, use it like this (adding "utf8" as argument #4). --- Best regards, Melancholie (talk) 10:35, 30 January 2009 (UTC)[reply]
Did you test it? I get errors like:
 C:\Documents and Settings\Nils\Desktop\upload1>perl upload.pl - - - utf8
Global symbol "$csv" requires explicit package name at upload.pl line 124.
Global symbol "$csv" requires explicit package name at upload.pl line 125.
Global symbol "$csv" requires explicit package name at upload.pl line 388.
Global symbol "$csv" requires explicit package name at upload.pl line 389.
Execution of upload.pl aborted due to compilation error
and
 Global symbol "$csv" requires explicit package name at upload.pl line 124.
Global symbol "$csv" requires explicit package name at upload.pl line 125.
Global symbol "$csv" requires explicit package name at upload.pl line 388.
Global symbol "$csv" requires explicit package name at upload.pl line 389.
Execution of upload.pl aborted due to compilation errors.
I give up... sorry. Faster to do it manually Nillerdk (talk) 08:46, 27 February 2009 (UTC)[reply]
Someone made a very silly mistake. $csv had been declared, but as my $csv within a subroutine. So the rest of the program will not know any variable like that. Hence the cryptic "requires explicit package" error. Change it into this:

#CSV Parser
my $csv;
if (defined $ARGV[3] && $ARGV[3] =~ /^UTF-?8$/i) {
 $csv = Text::CSV::Encoded->new({ encoding  => "utf8" });
} else {
 $csv = Text::CSV_XS->new({ binary => 1});
}

Ger Hanssen (talk) 14:08, 20 March 2009 (UTC)[reply]
More fixes, otherwise you'll get an error when using permission value 1 or 7, of which the first is quite likely to be used.

#################################
#Permissions
	if ($permission_value == 0)	
            {
            defaultlicence:	 
            print "Enter custom permission: ";
            $licence = <STDIN>;
            $permission_value = $licence; # line added, Ger Hanssen 2009-03-20
            }
 	elsif (($permission_value >= 1) &&  ($permission_value <= 7)) # equal signs added, Ger Hanssen 2009-03-20
            {
            $licence= $permission[$permission_value];
            }
	else {print "Invalid licence\n"; goto defaultlicence;}

$exif_permission_text = $exif_permission_information[$permission_value];

Ger Hanssen (talk) 21:54, 20 March 2009 (UTC)[reply]

Thank you Ger Hanssen! @Nillerdk: The cause had been the first issue pointed out by Ger Hanssen (a silly copy&paste frivolity /o\). Unfortunately, the script seems to not have any active maintainer anymore, and I myself just do not have anything to upload and test with; furthermore I cannot (and thus did not) properly test it because the script execution aborts for me because of missing/unavailable exif module(s). Sorry! Because of this and that I will add this page to my RSS watchlist. @Ger Hanssen: I also have added/changed your second code changes to the original code, thanks again! --- Best regards, Melancholie (talk) 04:33, 26 March 2009 (UTC)[reply]

Cant find the file error[edit]

Hi, I get the error below when trying to run the upload script. Can some help me with it? --Jarekt (talk) 03:53, 1 May 2009 (UTC)[reply]

C:\Perl\images>C:\Perl\bin\perl upload.pl
Malformed UTF-8 character (unexpected continuation byte 0xa9, with no preceding start byte) at upload.pl line 713.
Malformed UTF-8 character (unexpected continuation byte 0xa9, with no preceding start byte) at upload.pl line 714.
Embedding Exif information to Joshua_Tree_-_Dandelion_1.jpg... Successful!
Uploading Joshua_Tree_-_Dandelion_1.jpg to the Wikimedia Commons.
Description: Joshua Tree National Park: Climbing Dandelion 5.10a route on Old Woman Rock in Hidden Valey Campground
Can't open file Joshua_Tree_-_Dandelion_1.jpg: No such file or directory at C:/Perl/lib/LWP/UserAgent.pm line 434

The last message says that file "Joshua_Tree_-_Dandelion_1.jpg" is missing where it was expected with that name, most probably because of the initial UTF-8 issue: This should be fixed with the new version (1.3.1), use that one. If the message still appears, please leave a note. To get it working then you may use the script in plain non-utf mode (if there are only ASCII characters in names (English)), see User:Nichalp/Upload_script#Executing_the_script. --- Best regards, Melancholie (talk) 13:51, 7 May 2009 (UTC)[reply]

Problem?[edit]

Well since Commonist is out of action at the moment and I dislike python scripting, I thought I use this perl script but it is giving me nothing but a headache.

I've done everything that is said but I get this.

C:\Users\Public\Documents\commonsupload>perl upload.pl - - - utf8 Enter your Commons username: Bidgee Enter your Commons password: <removed> '1/250 Use of uninitialized value $shutter in concatenation (.) or string at upload.pl line 523, <$data> line 2.


Embedding Exif information to A_rally_in_protest_of_Wagga_City_Council's_plannin g_department_1.jpg... Successful! Uploading A_rally_in_protest_of_Wagga_City_Council's_planning_department_1.jpg t o the Wikimedia Commons. Description: A rally of locals in protest of Wagga City Council's planning depar tment. Can't open file A_rally_in_protest_of_Wagga_City_Council's_planning_department_1 .jpg: No such file or directory at C:/Perl/lib/LWP/UserAgent.pm line 427

I've tried a few ideas of my own (such as downloading new lib files and running Perl to install them) but still the same error. Bidgee (talk) 12:53, 10 April 2010 (UTC)[reply]

Ok problem found, use a different name to the file name you want to use on Commons. Bidgee (talk) 13:31, 10 April 2010 (UTC)[reply]
Maybe not, says it uploaded but it hasn't!


Renaming 1.jpg to A_rally_in_protest_of_Wagga_City_Council_planning_department1. jpg... Successful! Embedding Exif information to A_rally_in_protest_of_Wagga_City_Council_planning_ department1.jpg... Successful! Uploading A_rally_in_protest_of_Wagga_City_Council_planning_department1.jpg to t he Wikimedia Commons. Description: A rally of locals in protest of Wagga City Council planning departm ent. Uploaded successfully. '1/500 1/500


Renaming 2.jpg to A_rally_in_protest_of_Wagga_City_Council_planning_department2. jpg... Successful! Embedding Exif information to A_rally_in_protest_of_Wagga_City_Council_planning_ department2.jpg... Successful! Uploading A_rally_in_protest_of_Wagga_City_Council_planning_department2.jpg to t he Wikimedia Commons. Description: A rally of locals in protest of Wagga City Council planning departm ent. Uploaded successfully. All OK. Log written to debug.txt. Bidgee (talk) 13:35, 10 April 2010 (UTC)[reply]

Error running upload.pl[edit]

I am trying to get this script which looks very useful to run. I am running on Windows and I believe I have installed everything according to User:Nichalp/Upload_script/installation#Windows. When I run the upload.pl I get the following:

C:\Perl\pictures>perl upload.pl
Can't locate Text/CSV/Encoded.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at upload.pl line 31.
BEGIN failed--compilation aborted at upload.pl line 31.

Any ideas? --Captain-tucker (talk) 20:46, 3 May 2010 (UTC)[reply]

I'm getting the same error as the Cap'n. Also, I tried using the old upload script and it was having login issues. This one uses a very similar routine. I tried pasting the login routine from this script into the old one by Eloquence. Still having issues getting that script to log in at all. Is this script broken now? File Upload Bot (Timscaffidi) (talk) 05:14, 12 May 2010 (UTC)[reply]


I have same error in Fedora 13/Perl 5.10.1/upload.pl 1.3.1

./upload.pl 
Can't locate Text/CSV/Encoded.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5 /usr/share/perl5     
/usr/lib64/perl5 /usr/share/perl5 /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl .) at ./upload.pl line 31.
BEGIN failed--compilation aborted at ./upload.pl line 31.

This appears to be associated with Text-CSV_XS-0.80 The install did

make install
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" CSV_XS.PL CSV_XS
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/Text/CSV_XS/CSV_XS.so
Installing /usr/local/lib64/perl5/auto/Text/CSV_XS/CSV_XS.bs
Installing /usr/local/lib64/perl5/Text/CSV_XS.pm
Installing /usr/local/share/man/man3/Text::CSV_XS.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod

I can't find an Encoded.pm on my system. Yum denies any knowledge of it. Perhaps the latest Text-CSV_XS has broken this? User:Andy.Cowley(talk) Friday, March 11 2011

upload.pl replacement[edit]

Hi,

since upload.pl has login issues I have created a replacement, written in python: anuta.py (https://launchpad.net/anuta) It can be downloaded here: https://launchpad.net/anuta/+download

It's not well tested yet, but I managed to upload 266 photos already with it: http://commons.wikimedia.org/wiki/Category:Files_uploaded_by_Wmigda%27s_script, even with Polish, Japanese, and Korean UTF-8-encoded descriptions.

Cheers, Wmigda (talk) 21:54, 21 June 2010 (UTC)[reply]

10 years later :
This anuta Script typically fails due to missing module mechanize. I did a apt-get install python-mechanize and anuta.py worked ... nearly ... --Itu (talk) 11:06, 25 October 2020 (UTC)[reply]
Now it's working ... with some issues .... --Itu (talk) 00:08, 31 October 2020 (UTC)[reply]

Bot account[edit]

"... consider getting a bot account to prevent the script from flooding the recent changes list."

What is meant? What is a bot account? What is the recent changes list? Why should I care? Regards, ... PeterEasthope (talk) 15:15, 22 September 2019 (UTC)[reply]