VxJasonxV / MusicBrainz-Track-Parsers

A collection of scripts for used to output music tag information in a format suitable for insertion into MusicBrainz' Track Parser
10 stars 4 forks source link

Terminal tells me that there's an issue with the code #5

Closed willfbren closed 10 years ago

willfbren commented 10 years ago

I've installed all the proper modules for perl and still get this issue when trying to parse the beatport release.

$ perl beatport.pl "http://www.beatport.com/release/low-key-ep/131754"
defined(@array) is deprecated at beatport.pl line 8.
    (Maybe you should just omit the defined()?)
malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at beatport.pl line 51.

Any suggestions?

VxJasonxV commented 10 years ago

Pull updates. defined isn't located in the script at all anymore.

I just tested it against the current version, and it works fine. You may be running an older commit.

willfbren commented 10 years ago

Great thank you! Was running against older version.

This is the error I get now: html.query error - The query does not contain any elements

Sorry if this is basic stuff, I'm learning slowly.

willfbren commented 10 years ago

Any ideas?

That is the error when passing a URL thru the parser.

VxJasonxV commented 10 years ago

That's happening still when running the perl script? Like I said initially, I passed your exact command line in and had no issues whatsoever. My web browser opens with the submission button, and there is no output on the command line, indicating a successful execution.

I suspect that you're not actually getting the Beatport web page when you run it, but I wouldn't have the slightest idea why.

Since I don't really have any debugging already implemented, we can probably use the perl debugger to figure this out:

Run perl -d beatport.pl "http://www.beatport.com/release/low-key-ep/131754"

You should see the following output:


Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(beatport.pl:32): my $URI = shift @ARGV unless not @ARGV;
  DB<1>

Here, type c 39 and press enter. You'll get a single line back:

  DB<1> c 39
main::(beatport.pl:39): my $c = Query( text => $content, 'div.release-detail' );
  DB<2>

Here, you can run x $content and copy the output. There will be a lot. Hopefully it will be pretty obvious (to me) whether or not it's the webpage we're looking for.

willfbren commented 10 years ago

Thank you man. I'll run that in the morning and let you know what I get.

Thanks for all your help. I really like perl and beets and I'm just trying to learn more about it. If you have any sites I should check out that would futher my understanding/tutorials, please pass those along. I want to learn as much as I can.

On Tuesday, July 22, 2014, Jason Salaz notifications@github.com wrote:

That's happening still when running the perl script? Like I said initially, I passed your exact command line in and had no issues whatsoever. My web browser opens with the submission button, and there is no output on the command line, indicating a successful execution.

I suspect that you're not actually getting the Beatport web page when you run it, but I wouldn't have the slightest idea why.

Since I don't really have any debugging already implemented, we can probably use the perl debugger to figure this out:

Run perl -d beatport.pl "http://www.beatport.com/release/low-key-ep/131754 "

You should see the following output:

Loading DB routines from perl5db.pl version 1.37 Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(beatport.pl:32): my $URI = shift @ARGV unless not @ARGV; DB<1>

Here, type c 39 and press enter. You'll get a single line back:

DB<1> c 39 main::(beatport.pl:39): my $c = Query( text => $content, 'div.release-detail' ); DB<2>

Here, you can run x $content and copy the output. There will be a lot. Hopefully it will be pretty obvious (to me) whether or not it's the webpage we're looking for.

— Reply to this email directly or view it on GitHub https://github.com/VxJasonxV/MusicBrainz-Track-Parsers/issues/5#issuecomment-49707153 .

::::::::::::::::::::::::::::::::::::::::::::::::::

WILLIAM BRENNAN TRUMPET

p. 504.202.8433

willfbren@gmail.com william@trumpetgroup.com http://www.trumpetgroup.com

willfbren commented 10 years ago

So this is odd... I get a webpage but for some reason it looks like it's the checkout page on Beatport?

'<!DOCTYPE HTML><html class=""
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml"
      data-cache-splinter="31368b26f57d01484889efe2a74be078c21d17bd"
      data-ga-code="UA-651667-46"><head><meta id="chromeframe-meta" http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" data-min-version="7"><meta name="google-site-verification" content="HiWDRNXGkBZWkW5td68yMj5zwjAvFH4NqOcAeh41u5s"><meta property="twitter:account_id" content="31141686" /><script>

    var BP = BP || {};

            var __gigyaConf = __gigyaConf || {};
    __gigyaConf.APIKey = "3_JzNgG7gNChl8CxWWaRY-jwRY3k4jEz7mHq5UVL1UA4w6_wP5JROPTvNewJ8qX1Wp";
    __gigyaConf.extraFields = "languages, address, phones, education, honors, publications, patents, certifications, professionalHeadline, bio, industry, specialties, work, skills, religion, politicalView, interestedIn, relationshipStatus, hometown, favorites, likes, username, locale, verified, irank, timezone";
    __gigyaConf.siteName = "beatport.com";
    __gigyaConf.enabledProviders = "facebook,twitter,google,paypal";

        BP.messages = BP.messages || {"checkout":"Checkout","undo":"Undo","ok":"OK","cancel":"Cancel","close":"Close","yes":"Yes","no":"No","noThanks":"No Thanks","thankYou":"Thank You","areYouSure":"Are you sure?","allItemsWillBeRemovedFromCart":"All of the items in your cart will be removed.","allItemsWillBeRemovedFromHoldBin":"All of the items in your hold bin will be removed.","movedToHoldBin":"was moved to your hold bin.","removedFromCart":"was removed.","clearPlaylist":"Empty Queue","showMore":"More...","showLess":"Less...","clickToAdd":"Click to Add","djAlreadyAdded":"DJ Already Added to Line-Up.","creditCardRequired":"Please enter a credit card number.","invalidCreditCard":"The number entered is not a valid credit card number.","pleaseChooseCountry":"Please choose a country.","pleaseEnterAddress":"Please enter your address.","pleaseEnterCity":"Please enter your city.","pleaseEnterPostalCode":"Please enter a postal code","viewYourProfile":"View your profile","addItemToDJProfile":"Add this %item to my DJ Profile","pleaseEnterValidSoundcloudUrl":"Please enter a valid soundcloud track url","invalidSoundcloudTrack":"Error adding soundcloud track. Please check the URL and try again.","flashRequiredForVideos":"In order to view videos, please download the latest Flash Player.","errorSavingChanges":"Error saving changes. Please try again.","pinOpen":"Pin Open","removePin":"Remove Pin","profileNotCreated":"You Haven\'t Created Your DJ Profile Yet!","joinProfiles":"Join thousands of others in our on-line DJ Profiles","createProfile":"Create Profile","timeAgo":"ago","timeFromNow":"from now","timeLessThanAMinute":"less than a minute","timeAboutAMinute":"about a minute","timeNumMinutes":"%num minutes","timeAboutAHour":"about an hour","timeNumHours":"about %num hours","timeAboutADay":"a day","timeNumDays":"%num days","timeAboutAMonth":"about a month","timeNumMonths":"%num months","timeAboutAYear":"about a year","timeNumYears":"%num years","requiredField":"This field is required.","enterValidEmail":"Please enter a valid email address.","enterSameValue":"Please enter the same value again.","detailedPasswordRequirements":"For your security your password must contain at least 1 letter ( A-Z, a-z ), 1 digit ( 0-9 ), be at least 8 characters and cannot contain spaces.","minLength":"Please enter at least {0} characters.","maxLength":"Please enter no more than {0} characters.","fixThisField":"Please fix this field.","enterValidUrl":"Please enter a valid URL.","enterValidDate":"Please enter a valid date.","enterValidDateIso":"Please enter a valid date (ISO).","enterValidNumber":"Please enter a valid number.","enterOnlyDigits":"Please enter only digits.","enterValidExtension":"Please enter a value with a valid extension.","enterValidLengthRange":"Please enter a value between {0} and {1} characters long.","enterValidRange":"Please enter a value between {0} and {1}.","maxValue":"Please enter a value less than or equal to {0}.","minValue":"Please enter a value greater than or equal to {0}.","invalidPostalCodeCanada":"Your postal code is formatted incorrectly. Example: A1B 2C3","invalidPostalCodeUS":"Your postal code is formatted incorrectly. Example: 12345-6789 OR 12345","noSpecialCharacters":"Field cannot contain any special characters.","expirationDateInPast":"Expiration Date must not be in the past","enterNameForChart":"Please enter a name for this chart.","changeDefaultAudioFormat":"Would you like to change your default format to %d?","audioFormatPreferences":"Audio Format Preferences","notAValidPaymentMethod":"The card number entered is not one of our accepted payment methods."};

I was talking to another user and the only thing we noticed different in our setups were when he runs: which perl his output is: /opt/local/bin/perl

When I run which perl my output is /usr/bin/perl

We were checking to make sure my perl version was up-to-date I believe. Thanks for your help.

VxJasonxV commented 10 years ago

It's definitely not the checkout page. There's tons of information pre-loaded in order to get AJAX to work for them. Think of it this way: Beatport's site doesn't use frames, but the audio player continues to work while you browse around the site. This is accomplished by having a ton of information available in every page, and updating only the necessary pieces of the site as you browse from page to page.

Your friend installed perl via some third party system. Macports, Homebrew, or something else like those, where you're using the built-in system version. If you were able to install the modules, then I don't think a version discrepancy is to blame here.

I'm thinking about the best way to try and debug this, which more than likely means adding new code to find parts of the page and report them. Might mean learning more about the debugger. We'll see.

VxJasonxV commented 10 years ago

It's local to your machine, but that doesn't mean it's not a bug. It can be both, the two are not mutually exclusive. Version numbers and interactivity and all that stuff is hard.

willfbren commented 10 years ago

Figured the issue out. Did not have perl installed at the user level. Only at the root. Not sure why it couldn't run at root, but as soon as all packages were installed at user level, works perfectly.

Thanks for the parser!

VxJasonxV commented 10 years ago

I don't entirely understand that explanation. If you were missing perl, the script wouldn't run at all, running perl would say "command not found". If you were missing HTML::Query, the script wouldn't have run at all and you would have gotten an error loading that package. But both happened, perl ran and you got a very specific message from HTML::Query indicating it functioned, but couldn't fulfill the request.

Can you tell me exactly what you did to fix it?

willfbren commented 10 years ago

Sorry for the confusion. Not sure of all the proper lingo.

What I found fixed it was this:

I had originally installed perl and all the modules at ~HD/Library/perl. (I'm on a Mac).

That is when I was getting the errors. First, because I didn't pull the latest version then the HTML query error that nothing was defined. I do have HTML::Query installed in that library though, so I'm not sure why I was getting that error.

After you mentioned Macports, I did some research and installed perl using Macports. This time it installed at ~HD/Users/William/perl. This is what I meant by "user level". Made sure I had all the proper modules installed and voila. Worked like a charm.

I'm very new to command line languages and the proper terms. Let me know if this explanation makes better sense.