#!/usr/bin/perl
#line 1 batchaddars.in

#line 2 batchaddars.in
use warnings;
#line 3 batchaddars.in
use strict;
#line 4 batchaddars.in

#line 5 batchaddars.in
use URI;
#line 6 batchaddars.in

#line 7 batchaddars.in
my ($BROWSER) = "firefox";
#line 8 batchaddars.in
my (@ARGUMENTS) = "--new-tab";
#line 9 batchaddars.in

#line 10 batchaddars.in
#use Data::Dumper;
#line 11 batchaddars.in

#line 12 batchaddars.in
# lookup tables.
#line 13 batchaddars.in
my (%Vocal) = (
  'alto' => '5',
  'background' => '12',
  'baritone' => '6',
  'bass' => '7',
  'bass-baritone' => '231',
  'choir' => '13',
  'contra-tenor' => '8',
  'contralto' => '230',
  'lead' => '4',
  'mezzo-soprano' => '9',
  'soprano' => '10',
  'tenor' => '11'
)
;
#line 14 batchaddars.in
my (%Instrument) = (
  '[select instrument]' => '0',
  'accordion' => '64',
  'acoustic bass guitar' => '73',
  'acoustic guitar' => '76',
  'acoustic upright bass' => '71',
  'aeolian harp' => '89',
  'afuche' => '136',
  'alphorn' => '41',
  'alto clarinet' => '24',
  'alto flute' => '423',
  'alto recorder' => '363',
  'alto saxophone' => '35',
  'alto violin' => '226',
  'appalachian dulcimer' => '90',
  'aracaic and other bowed string-instruments' => '296',
  'bagpipe' => '18',
  'balalaika' => '91',
  'bandoneón' => '263',
  'banghu' => '291',
  'banhu' => '291',
  'banjo' => '92',
  'bansuri' => '251',
  'baritone guitar' => '377',
  'baritone horn' => '42',
  'baritone saxophone' => '37',
  'bass' => '70',
  'bass clarinet' => '25',
  'bass guitar' => '277',
  'bass recorder' => '365',
  'bass trombone' => '228',
  'bassoon' => '19',
  'bells' => '151',
  'bendir' => '420',
  'berimbau' => '93',
  'biwa' => '94',
  'bodhrán' => '249',
  'bongos' => '128',
  'bouzouki' => '95',
  'bowed psaltery' => '299',
  'bowed string instruments' => '275',
  'brass' => '38',
  'brushes' => '397',
  'bugle' => '51',
  'bull-roarer' => '202',
  'c-bass recorder' => '366',
  'cabasa' => '136',
  'cajón' => '413',
  'calliope' => '170',
  'carillon' => '171',
  'castanets' => '137',
  'celesta' => '172',
  'cello' => '84',
  'chacha' => '412',
  'chamberlin' => '330',
  'chapman stick' => '238',
  'chimes' => '415',
  'chiêng' => '341',
  'chromatic harmonica' => '376',
  'chập choa' => '343',
  'cittern' => '307',
  'cizhonghu' => '288',
  'clarinet' => '23',
  'classical guitar' => '77',
  'claves' => '138',
  'clavichord' => '173',
  'clavinet' => '227',
  'concertina' => '65',
  'conch' => '205',
  'congas' => '127',
  'contrabass' => '83',
  'contrabass clarinet' => '26',
  'contrabass recorder' => '367',
  'contrabassoon' => '20',
  'cornet' => '39',
  'cornett' => '273',
  'cowbell' => '208',
  'crotales' => '214',
  'crwth' => '98',
  'cymbals' => '342',
  'cymbalum' => '326',
  'daf' => '403',
  'dan trung and dan klom-put' => '381',
  'darbuka' => '419',
  'denis d\'or' => '160',
  'didgeridoo' => '204',
  'dinh tăktàr' => '394',
  'diyingehu' => '290',
  'djembe' => '335',
  'dobro' => '240',
  'double bass' => '83',
  'double reed' => '17',
  'doyra' => '140',
  'drum machine' => '162',
  'drums' => '125',
  'drumset' => '126',
  'dubreq stylophone' => '161',
  'ebow' => '404',
  'electric bass guitar' => '74',
  'electric cello' => '278',
  'electric guitar' => '78',
  'electric piano' => '329',
  'electric sitar' => '316',
  'electric upright bass' => '72',
  'electric violin' => '282',
  'electronic instruments' => '159',
  'english horn' => '21',
  'euphonium' => '199',
  'f-bass recorder' => '365',
  'fiddle' => '85',
  'fipple flutes' => '264',
  'flugelhorn' => '43',
  'flute' => '27',
  'frame drum' => '421',
  'free reed' => '63',
  'french horn' => '44',
  'gadulka' => '301',
  'gaohu' => '286',
  'garklein recorder' => '361',
  'gayageum' => '99',
  'gehu' => '289',
  'geomungo' => '100',
  'ghatam' => '408',
  'glass (h)armonica' => '357',
  'glockenspiel' => '215',
  'goblet drum' => '338',
  'gong' => '340',
  'gongs' => '339',
  'grand piano' => '181',
  'great bass recorder' => '366',
  'greek baglama' => '306',
  'gudok' => '300',
  'guitar' => '229',
  'guitars' => '75',
  'gumbri' => '402',
  'güiro' => '141',
  'hammered dulcimer' => '101',
  'hammond organ' => '177',
  'handbells' => '346',
  'handclaps' => '398',
  'hardart' => '187',
  'hardingfele' => '102',
  'harmonica' => '66',
  'harmonium' => '178',
  'harp' => '81',
  'harpsichord' => '174',
  'hawaiian guitar' => '400',
  'heckelphone' => '261',
  'hmông flute' => '389',
  'horn' => '40',
  'huqin' => '283',
  'hurdy gurdy' => '103',
  'jew\'s harp' => '104',
  'jing hú' => '284',
  'k\'long pút' => '355',
  'kanun' => '360',
  'kazoo' => '188',
  'kemenche' => '281',
  'keyboard' => '232',
  'keyed brass instruments' => '203',
  'khen la´' => '388',
  'khim' => '359',
  'khèn meò' => '395',
  'ki pah' => '384',
  'kinnor' => '317',
  'kithara' => '318',
  'koke' => '386',
  'kokyu' => '293',
  'komungo' => '105',
  'kora' => '106',
  'kortholt' => '334',
  'koto' => '107',
  'kèn bầu' => '380',
  'la' => '341',
  'langeleik' => '319',
  'lasso d\'amore' => '189',
  'lute' => '108',
  'lyre' => '109',
  'madal' => '242',
  'mandola' => '308',
  'mandolin' => '96',
  'maracas' => '142',
  'marimba' => '216',
  'matouqin' => '294',
  'mbira' => '110',
  'mellophone' => '56',
  'mellotron' => '175',
  'melodica' => '67',
  'mendoza' => '143',
  'mexican vihuela' => '117',
  'minimoog' => '349',
  'moog' => '348',
  'moon lute' => '310',
  'morin khuur' => '294',
  'musical bow' => '97',
  'musical saw' => '190',
  'mõ' => '337',
  'nai' => '369',
  'natural brass instruments' => '49',
  'nose flute' => '270',
  'nyckelharpa' => '298',
  'não bạt' => '343',
  'oboe' => '22',
  'ocarina' => '29',
  'omnichord' => '352',
  'ondes martenot' => '163',
  'ophicleide' => '57',
  'organ' => '176',
  'other flutes' => '265',
  'other instruments' => '185',
  'other percussion' => '221',
  'other string instruments' => '88',
  'oud' => '304',
  'pan flute' => '30',
  'pang gu ly hu hmông' => '392',
  'percussion instruments' => '124',
  'phách' => '379',
  'piano' => '180',
  'piccolo' => '31',
  'pipe organ' => '179',
  'plucked string instruments' => '302',
  'programming' => '353',
  'psaltery' => '111',
  'pí thiu' => '416',
  'ratchet' => '211',
  'rattle' => '411',
  'rebab' => '309',
  'rebec' => '276',
  'recorder' => '32',
  'reed organ' => '274',
  'reeds' => '233',
  'rek' => '406',
  'rhodes piano' => '182',
  'sackbut' => '198',
  'sampler' => '164',
  'sanh tiên' => '347',
  'sanshin' => '315',
  'santoor' => '358',
  'santur' => '325',
  'sanxián' => '314',
  'sapek clappers' => '418',
  'sarod' => '250',
  'saxophone' => '33',
  'saó ôi flute' => '387',
  'serpent' => '197',
  'shakers' => '417',
  'shakuhachi' => '224',
  'shamisen' => '112',
  'sheng' => '68',
  'sho' => '262',
  'shofar' => '60',
  'singing bowl' => '191',
  'singular reed' => '234',
  'sitar' => '113',
  'slide brass instruments' => '272',
  'slide guitar' => '79',
  'slide whistle' => '268',
  'snare drum' => '129',
  'song loan' => '356',
  'sopranino recorder' => '362',
  'soprano saxophone' => '34',
  'soprano violin' => '280',
  'sousaphone' => '200',
  'spanish acoustic guitar' => '206',
  'spanish vihuela' => '332',
  'spoons' => '210',
  'steel guitar' => '80',
  'steelpan' => '344',
  'string instruments' => '69',
  'struck string instruments' => '322',
  'subcontrabass recorder' => '368',
  'suikinkutsu' => '192',
  'synclavier' => '165',
  'synthesizer' => '166',
  'syrinx' => '370',
  'sáo meò' => '393',
  'sáo trúc' => '269',
  'tabla' => '241',
  'tambourine' => '333',
  'tanbou ka' => '410',
  'teleharmonium' => '167',
  'temple blocks' => '222',
  'tenor horn (alto horn)' => '45',
  'tenor recorder' => '364',
  'tenor saxophone' => '36',
  'theremin' => '168',
  'ti bwa' => '409',
  'tibetan water drum' => '350',
  'tieu flute' => '401',
  'timbales' => '132',
  'timpani' => '217',
  'tin whistle' => '267',
  'tiple' => '331',
  'tiểu cô' => '336',
  'toy piano' => '328',
  'tranverse flute' => '422',
  'treble recorder' => '363',
  'treble violin' => '279',
  'tres' => '115',
  'triangle' => '133',
  'trombone' => '46',
  'trumpet' => '47',
  'tràm plè' => '385',
  'trắng jâu' => '391',
  'trắng lu' => '390',
  'trống bông' => '382',
  'tuba' => '48',
  'tubular bells' => '218',
  'tuned percussion' => '150',
  'turkish baglama' => '305',
  'turntable(s)' => '236',
  'udu' => '407',
  'uilleann pipes' => '248',
  'ukulele' => '114',
  'upright piano' => '184',
  'vacuum cleaner' => '375',
  'valve trombone' => '237',
  'valved brass instruments' => '271',
  'vertical flute' => '28',
  'vibraphone' => '219',
  'vibraslap' => '212',
  'vielle' => '116',
  'vietnamese guitar' => '399',
  'viola' => '87',
  'viola d\'amore' => '119',
  'viola da gamba' => '118',
  'viola organista' => '297',
  'violin' => '86',
  'violins' => '82',
  'violotta' => '120',
  'vocoder' => '354',
  'wagner tuba' => '201',
  'warr guitar' => '323',
  'washboard' => '209',
  'washtub bass' => '121',
  'waterphone' => '351',
  'whip' => '134',
  'whistle' => '345',
  'willow flute' => '266',
  'wind instruments' => '15',
  'wood block' => '213',
  'woodwind' => '16',
  'xalam (khalam)' => '122',
  'xylophone' => '220',
  'yehu' => '292',
  'yángqín' => '324',
  'zarb' => '405',
  'zhonghu' => '287',
  'zhongruan' => '311',
  'zither' => '123',
  'Èrhú' => '285',
  'Đing buốt' => '383',
  'Đing nǎm' => '396',
  'Đàn bầu' => '321',
  'Đàn nguyệt' => '312',
  'Đàn nhị' => '295',
  'Đàn tam' => '414',
  'Đàn tam thập lục' => '327',
  'Đàn tranh' => '320',
  'Đàn tứ dây' => '303',
  'Đàn tỳ bà' => '313',
  'Đại cô' => '336'
)
;
#line 15 batchaddars.in
my (%Orchestra) = (
  'chamber' => '245',
  'other' => '246',
  'symphony' => '244'
)
;
#line 16 batchaddars.in
my (%Type) = (
  'artist' => {
    'artist' => {
      'collaborated on' => '11',
      'does/did support for' => '15',
      'does/did vocal support for' => '14',
      'has sibling' => '7',
      'is the parent of' => '6',
      'is/was a supporting musician for' => '13',
      'is/was amember of' => '2',
      'is/was involved with' => '9',
      'is/was married to' => '8',
      'musical relationship' => '1',
      'performs as' => '4',
      'personal relationship' => '5'
    },
    'release' => {
      '[select a relationship type]' => '0',
      'arranged' => '15',
      'audio engineered' => '20',
      'compilations' => '40',
      'compiled' => '41',
      'composed' => '14',
      'composition' => '13',
      'conducted' => '9',
      'dj-mixed' => '38',
      'engineered' => '19',
      'has a miscellaneous role on' => '25',
      'has tribute album(s)' => '44',
      'live sound engineered' => '22',
      'mastered' => '45',
      'mixed' => '23',
      'orchestra performed' => '5',
      'orchestrated' => '48',
      'performance' => '1',
      'performed' => '2',
      'performed chorus master on' => '43',
      'performed on' => '3',
      'performed vocal on' => '4',
      'produced' => '18',
      'produced material that was sampled in' => '12',
      'production' => '17',
      'provided art direction on' => '30',
      'provided artist &amp; repertoire support for' => '28',
      'provided booking for' => '27',
      'provided creative direction on' => '29',
      'provided design/illustration on' => '31',
      'provided graphic design on' => '32',
      'provided instrumentation for' => '47',
      'provided legal representation for' => '26',
      'provided merchandising for' => '36',
      'provided photography on' => '33',
      'provided travel arrangements for' => '34',
      'published' => '35',
      'recorded' => '24',
      'remixed' => '11',
      'remixes' => '10',
      'sound engineered' => '21',
      'wrote the libretto for' => '42',
      'wrote the lyrics for' => '16'
    },
    'track' => {
      'arranged' => '15',
      'audio engineered' => '20',
      'compilations' => '38',
      'compiled' => '39',
      'composed' => '14',
      'composition' => '13',
      'conducted' => '9',
      'dj-mixed' => '40',
      'engineered' => '19',
      'has a miscellaneous role on' => '25',
      'live sound engineered' => '22',
      'mastered' => '41',
      'mixed' => '23',
      'orchestra performed' => '5',
      'orchestrated' => '44',
      'performance' => '1',
      'performed' => '2',
      'performed on' => '3',
      'performed vocal on' => '4',
      'produced' => '18',
      'produced material that was sampled in' => '12',
      'production' => '17',
      'provided art direction on' => '30',
      'provided artist &amp; repertoire support for' => '28',
      'provided booking for' => '27',
      'provided creative direction on' => '29',
      'provided design/illustration on' => '31',
      'provided graphic design on' => '32',
      'provided instrumentation for' => '43',
      'provided legal representation for' => '26',
      'provided merchandising for' => '36',
      'provided photography on' => '33',
      'provided travel arrangements for' => '34',
      'published' => '35',
      'recorded' => '24',
      'remixed' => '11',
      'remixes' => '10',
      'sound engineered' => '21',
      'wrote the lyrics for' => '16'
    }
  },
  'release' => {
    'artist' => {
      '[select a relationship type]' => '0',
      'arranged' => '15',
      'audio engineered' => '20',
      'compilations' => '40',
      'compiled' => '41',
      'composed' => '14',
      'composition' => '13',
      'conducted' => '9',
      'dj-mixed' => '38',
      'engineered' => '19',
      'has a miscellaneous role on' => '25',
      'has tribute album(s)' => '44',
      'live sound engineered' => '22',
      'mastered' => '45',
      'mixed' => '23',
      'orchestra performed' => '5',
      'orchestrated' => '48',
      'performance' => '1',
      'performed' => '2',
      'performed chorus master on' => '43',
      'performed on' => '3',
      'performed vocal on' => '4',
      'produced' => '18',
      'produced material that was sampled in' => '12',
      'production' => '17',
      'provided art direction on' => '30',
      'provided artist &amp; repertoire support for' => '28',
      'provided booking for' => '27',
      'provided creative direction on' => '29',
      'provided design/illustration on' => '31',
      'provided graphic design on' => '32',
      'provided instrumentation for' => '47',
      'provided legal representation for' => '26',
      'provided merchandising for' => '36',
      'provided photography on' => '33',
      'provided travel arrangements for' => '34',
      'published' => '35',
      'recorded' => '24',
      'remixed' => '11',
      'remixes' => '10',
      'sound engineered' => '21',
      'wrote the libretto for' => '42',
      'wrote the lyrics for' => '16'
    },
    'release' => {
      'compilations' => '8',
      'covers or other versions' => '1',
      'is a cover of' => '13',
      'is a dj-mix of' => '9',
      'is a live performance of' => '11',
      'is a mash-up of' => '5',
      'is a remaster of' => '3',
      'is a remix of' => '7',
      'is the earliest release of' => '2',
      'remixes' => '4'
    },
    'track' => {
      '[select a relationship type]' => '0',
      'provides samples for' => '2'
    }
  },
  'track' => {
    'artist' => {
      'arranged' => '15',
      'audio engineered' => '20',
      'compilations' => '38',
      'compiled' => '39',
      'composed' => '14',
      'composition' => '13',
      'conducted' => '9',
      'dj-mixed' => '40',
      'engineered' => '19',
      'has a miscellaneous role on' => '25',
      'live sound engineered' => '22',
      'mastered' => '41',
      'mixed' => '23',
      'orchestra performed' => '5',
      'orchestrated' => '44',
      'performance' => '1',
      'performed' => '2',
      'performed on' => '3',
      'performed vocal on' => '4',
      'produced' => '18',
      'produced material that was sampled in' => '12',
      'production' => '17',
      'provided art direction on' => '30',
      'provided artist &amp; repertoire support for' => '28',
      'provided booking for' => '27',
      'provided creative direction on' => '29',
      'provided design/illustration on' => '31',
      'provided graphic design on' => '32',
      'provided instrumentation for' => '43',
      'provided legal representation for' => '26',
      'provided merchandising for' => '36',
      'provided photography on' => '33',
      'provided travel arrangements for' => '34',
      'published' => '35',
      'recorded' => '24',
      'remixed' => '11',
      'remixes' => '10',
      'sound engineered' => '21',
      'wrote the lyrics for' => '16'
    },
    'release' => {
      '[select a relationship type]' => '0',
      'provides samples for' => '2'
    },
    'track' => {
      'compilations' => '10',
      'contains samples from' => '7',
      'covers or other versions' => '1',
      'is a compilation of' => '12',
      'is a cover of' => '5',
      'is a dj-mix of' => '13',
      'is a mash-up of' => '8',
      'is a medley of' => '14',
      'is a remaster of' => '3',
      'is a remix of' => '11',
      'is the earliest release of' => '2',
      'is the earliest version of' => '4',
      'remixes' => '6'
    }
  }
)
;
#line 17 batchaddars.in

#line 18 batchaddars.in
# the list of edits we are about to commit
#line 19 batchaddars.in
my (@edits);
#line 20 batchaddars.in

#line 21 batchaddars.in
# until the heat death of the universe
#line 22 batchaddars.in
while (1) {
#line 23 batchaddars.in
  # read in a stanza
#line 24 batchaddars.in
  my @lines;
#line 25 batchaddars.in
  my $nonblank = 0;
#line 26 batchaddars.in
  while(<>) {
#line 27 batchaddars.in
    chomp;
#line 28 batchaddars.in
    last if /^$/ && $nonblank;
#line 29 batchaddars.in
    next if /^#/;
#line 30 batchaddars.in
    $nonblank = 1;
#line 31 batchaddars.in
    push @lines, $_;
#line 32 batchaddars.in
  }
#line 33 batchaddars.in
  
#line 34 batchaddars.in
  # if we are out of stanzas, exit
#line 35 batchaddars.in
  last if $#lines == -1;
#line 36 batchaddars.in
  
#line 37 batchaddars.in
  # parse first and second entity
#line 38 batchaddars.in
  my ($type0, @id0) = parseEntityLine(shift @lines);
#line 39 batchaddars.in
  my ($type1, @id1) = parseEntityLine(shift @lines);
#line 40 batchaddars.in

#line 41 batchaddars.in
  #print join ",",$type0, $type1; print "\n";
#line 42 batchaddars.in
  #print join ",",@id0; print "\n";
#line 43 batchaddars.in
  #print join ",",@id1; print "\n";
#line 44 batchaddars.in

#line 45 batchaddars.in
  # Parse remaining lines, extract relationship parameters
#line 46 batchaddars.in
  my (%param) = map {
#line 47 batchaddars.in
    lc $1 => $_ if (s/^\s*(\w+)\s*[:=]?(?:\s*|$)//);
#line 48 batchaddars.in
  } @lines;
#line 49 batchaddars.in
  
#line 50 batchaddars.in
  # --- canonicalize parameters ---
#line 51 batchaddars.in
  #print Dumper(\%param);
#line 52 batchaddars.in
  
#line 53 batchaddars.in
  # Type
#line 54 batchaddars.in
  die "(Relationship) Type not specified" unless exists $param{type};
#line 55 batchaddars.in
  foreach (keys %{$Type{$type0}{$type1}}) {
#line 56 batchaddars.in
    $param{type} = $Type{$_}{$type0}{$type1} if exists $param{$_};
#line 57 batchaddars.in
    delete $param{$_};
#line 58 batchaddars.in
  }
#line 59 batchaddars.in
  $param{type} = $Type{$type0}{$type1}{$param{type}} 
#line 60 batchaddars.in
    if exists $Type{$type0}{$type1}{$param{type}};
#line 61 batchaddars.in

#line 62 batchaddars.in
  # Guest, Additional, Minor
#line 63 batchaddars.in
  foreach (qw(guest additional minor)) {
#line 64 batchaddars.in
    if (exists $param{$_}) {
#line 65 batchaddars.in
      if ($param{$_} =~ m/1|Y(es)?|^$/i) {
#line 66 batchaddars.in
        $param{$_} = 1;
#line 67 batchaddars.in
      } else {
#line 68 batchaddars.in
        $param{$_} = 0;
#line 69 batchaddars.in
      }
#line 70 batchaddars.in
    }
#line 71 batchaddars.in
  }
#line 72 batchaddars.in
  
#line 73 batchaddars.in
  # Vocal
#line 74 batchaddars.in
  foreach (keys %Vocal) {
#line 75 batchaddars.in
    $param{vocal} = $Vocal{$_} if exists $param{$_};
#line 76 batchaddars.in
    delete $param{$_};
#line 77 batchaddars.in
  }
#line 78 batchaddars.in
  $param{vocal} = $Vocal{$param{vocal}} 
#line 79 batchaddars.in
    if exists $param{vocal} && exists $Vocal{$param{vocal}};
#line 80 batchaddars.in

#line 81 batchaddars.in
  # Instrument
#line 82 batchaddars.in
  foreach (keys %Instrument) {
#line 83 batchaddars.in
    $param{instrument} = $Instrument{$_} if exists $param{$_};
#line 84 batchaddars.in
    delete $param{$_};
#line 85 batchaddars.in
  }
#line 86 batchaddars.in
  $param{instrument} = $Instrument{$param{instrument}}
#line 87 batchaddars.in
    if exists $param{instrument} && exists $Instrument{$param{instrument}};
#line 88 batchaddars.in

#line 89 batchaddars.in
  # Orchestra
#line 90 batchaddars.in
  foreach (keys %Orchestra) {
#line 91 batchaddars.in
    $param{orchestra} = $Orchestra{$_} if exists $param{$_};
#line 92 batchaddars.in
    delete $param{$_};
#line 93 batchaddars.in
  }
#line 94 batchaddars.in
  $param{orchestra} = $Orchestra{$param{instrument}}
#line 95 batchaddars.in
    if exists $param{orchestra} && exists $Orchestra{$param{orchestra}};
#line 96 batchaddars.in

#line 97 batchaddars.in
  # BeginDate -- YYYY-MM-DD
#line 98 batchaddars.in
  if (exists $param{begindate}) {
#line 99 batchaddars.in
    my ($date) = $param{begindate};
#line 100 batchaddars.in
    delete $param{begindate};
#line 101 batchaddars.in
    if ($date =~ m/(\d+)-(\d+)-(\d+)/) {
#line 102 batchaddars.in
      $param{begindate_y} = $1;
#line 103 batchaddars.in
      $param{begindate_m} = $2;
#line 104 batchaddars.in
      $param{begindate_d} = $3;
#line 105 batchaddars.in
    }
#line 106 batchaddars.in
  }
#line 107 batchaddars.in
  
#line 108 batchaddars.in
  # EndDate
#line 109 batchaddars.in
  if (exists $param{enddate}) {
#line 110 batchaddars.in
    my ($date) = $param{enddate};
#line 111 batchaddars.in
    delete $param{enddate};
#line 112 batchaddars.in
    if ($date =~ m/(\d+)-(\d+)-(\d+)/) {
#line 113 batchaddars.in
      $param{enddate_y} = $1;
#line 114 batchaddars.in
      $param{enddate_m} = $2;
#line 115 batchaddars.in
      $param{enddate_d} = $3;
#line 116 batchaddars.in
    }
#line 117 batchaddars.in
  }
#line 118 batchaddars.in

#line 119 batchaddars.in
  #print Dumper(\%param);
#line 120 batchaddars.in

#line 121 batchaddars.in
  # construct url...
#line 122 batchaddars.in

#line 123 batchaddars.in
  # type -> linktypeid
#line 124 batchaddars.in
  if ($param{type} =~ m/^\d+$/) {
#line 125 batchaddars.in
    $param{linktypeid} = $param{type};
#line 126 batchaddars.in
    delete $param{type};
#line 127 batchaddars.in
  } else {
#line 128 batchaddars.in
    die "(Relationship) Type '".$param{type}."' unknown";
#line 129 batchaddars.in
  }
#line 130 batchaddars.in
  
#line 131 batchaddars.in
  # additional -> attr_additional_0
#line 132 batchaddars.in
  if (exists $param{additional}) {
#line 133 batchaddars.in
    $param{attr_additional_0} = $param{additional};
#line 134 batchaddars.in
    delete $param{additional};
#line 135 batchaddars.in
  }
#line 136 batchaddars.in

#line 137 batchaddars.in
  # guest -> attr_guest_0
#line 138 batchaddars.in
  if (exists $param{guest}) {
#line 139 batchaddars.in
    $param{attr_guest_0} = $param{guest};
#line 140 batchaddars.in
    delete $param{guest};
#line 141 batchaddars.in
  }
#line 142 batchaddars.in

#line 143 batchaddars.in
  # minor -> attr_minor_0
#line 144 batchaddars.in
  if (exists $param{minor}) {
#line 145 batchaddars.in
    $param{attr_minor_0} = $param{minor};
#line 146 batchaddars.in
    delete $param{minor};
#line 147 batchaddars.in
  }
#line 148 batchaddars.in
  
#line 149 batchaddars.in
  # instrument -> attr_instrument_0
#line 150 batchaddars.in
  if (exists $param{instrument}) {
#line 151 batchaddars.in
    $param{attr_instrument_0} = $param{instrument};
#line 152 batchaddars.in
    delete $param{instrument};
#line 153 batchaddars.in
  }
#line 154 batchaddars.in
  
#line 155 batchaddars.in
  # orchestra -> attr_orchestra_0
#line 156 batchaddars.in
  if (exists $param{orchestra}) {
#line 157 batchaddars.in
    $param{attr_orchestra_0} = $param{orchestra};
#line 158 batchaddars.in
    delete $param{orchestra};
#line 159 batchaddars.in
  }
#line 160 batchaddars.in
  
#line 161 batchaddars.in
  # vocal -> attr_vocal_0
#line 162 batchaddars.in
  if (exists $param{vocal}) {
#line 163 batchaddars.in
    $param{attr_vocal_0} = $param{vocal};
#line 164 batchaddars.in
    delete $param{vocal};
#line 165 batchaddars.in
  }
#line 166 batchaddars.in

#line 167 batchaddars.in
  # note -> notetext
#line 168 batchaddars.in
  if (exists $param{note}) {
#line 169 batchaddars.in
    $param{notetext} = $param{note};
#line 170 batchaddars.in
    delete $param{note};
#line 171 batchaddars.in
  }
#line 172 batchaddars.in
  
#line 173 batchaddars.in
  #print Dumper(\%param);
#line 174 batchaddars.in
  
#line 175 batchaddars.in
  # Foreach (Entity1, Entity2) pair
#line 176 batchaddars.in
  foreach my $id0 (@id0) { foreach my $id1 (@id1) {
#line 177 batchaddars.in
    my (%edit) = (
#line 178 batchaddars.in
      link0 => $type0 . "=" . $id0,
#line 179 batchaddars.in
      link1 => $type1 . "=" . $id1,
#line 180 batchaddars.in
    );
#line 181 batchaddars.in
    foreach (keys %param) {
#line 182 batchaddars.in
      $edit{$_} = $param{$_};
#line 183 batchaddars.in
    }
#line 184 batchaddars.in
    push @edits, \%edit;
#line 185 batchaddars.in
  }}
#line 186 batchaddars.in
}
#line 187 batchaddars.in

#line 188 batchaddars.in
foreach my $edit (@edits) {
#line 189 batchaddars.in
  my $uri = new URI "http://musicbrainz.org/edit/relationship/add.html";
#line 190 batchaddars.in
  
#line 191 batchaddars.in
  $uri->query_form($edit);
#line 192 batchaddars.in
  
#line 193 batchaddars.in
  print $uri->as_string, "\n";
#line 194 batchaddars.in
  
#line 195 batchaddars.in
  # open a new tab in browser...
#line 196 batchaddars.in
  system $BROWSER, @ARGUMENTS, $uri->as_string;
#line 197 batchaddars.in

#line 198 batchaddars.in
  # Delay a few seconds to reduce load.
#line 199 batchaddars.in
  sleep 3 + rand(4);
#line 200 batchaddars.in
}
#line 201 batchaddars.in

#line 202 batchaddars.in
sub parseEntityLine {
#line 203 batchaddars.in
  my ($line) = @_;
#line 204 batchaddars.in
  
#line 205 batchaddars.in
  #print $line;
#line 206 batchaddars.in
  
#line 207 batchaddars.in
  # extract entity type from line
#line 208 batchaddars.in
  die "Could not find entity type" 
#line 209 batchaddars.in
    unless $line =~ s/^\s*(artist|release|track)(?::|\s)\s*//i;
#line 210 batchaddars.in
  
#line 211 batchaddars.in
  my ($type) = lc $1;
#line 212 batchaddars.in

#line 213 batchaddars.in
  # extract entities from line
#line 214 batchaddars.in
  my (@ids) = split /(?:,|\s)\s*/, $line; # )()
#line 215 batchaddars.in
  
#line 216 batchaddars.in
  die "No entities specified" if $#ids == -1;
#line 217 batchaddars.in

#line 218 batchaddars.in
  # Convert entityid(TrackID, etc...) to entity number (cache this data
#line 219 batchaddars.in
  # within an invocation)
#line 220 batchaddars.in
  #@ids = artistIDsToNumbers @ids if $type == "artist";
#line 221 batchaddars.in
  
#line 222 batchaddars.in
  return $type, @ids;
#line 223 batchaddars.in
}
#line 224 batchaddars.in
