Dalimil / Eventbrite-Tools

Eventbrite bot for securing tickets and getting all hidden ticket information. :robot: :stopwatch: :tickets:
Other
123 stars 26 forks source link

EventBrite Changed Something #3

Closed isianonpaper closed 4 years ago

isianonpaper commented 7 years ago

Tried running ticket-info.js (10/20 update) and it errored out. Instructions were to let you know. :+1:

Full code below with error message. Getting message on multiple pages (not isolated to one page). Had success as recent as two weeks ago.

ticket-info.js

function checkLocation() { if (location.href.indexOf("eventbrite") == -1) { console.log("You must go to the Eventbrite event page and run the script from there!"); throw new Error("You must go to the Eventbrite event page and run the script from there!"); } }

var EVENTBRITE_CHANGED_ERROR = "Eventbrite changed something and broke my script. Please let me know.";

function findCollection(data) { var pattern = /collection[\s:]+[{.*/g; var res = data.match(pattern); if(res == null || res.length == 0) { console.log("Ticket information is not available at this time. Finding alternative info..."); return null; } var collectionText = '{' + res[0].replace("collection", '"collection"') + '}'; collectionText = collectionText.replace(/\t/g, '');

var result = null;
try {
    result = JSON.parse(collectionText);
} catch(err) {
    console.log(EVENTBRITE_CHANGED_ERROR, err);
    throw err;
}
return result.collection;

}

function findModel(data) { var pattern = /model[\s:]+{.*},/g; var res = data.match(pattern); if(res == null || res.length == 0) { console.log(EVENTBRITE_CHANGED_ERROR); throw new Error(EVENTBRITE_CHANGED_ERROR); } var modelText = '{' + res[0].replace("model", '"model"').replace(/\t/g, ''); modelText = modelText.substr(0, modelText.lastIndexOf(",")) + '}';

var result = null;
try {
    result = JSON.parse(modelText);
} catch(err) {
    console.log(EVENTBRITE_CHANGED_ERROR, err);
    throw err;
}
return result.model;

}

function parseInteresting(collectionItem) { return { "name": collectionItem.name, "quantity": { "quantity_total": collectionItem.quantity_total, "quantity_sold": collectionItem.quantity_sold, "quantity_remaining": collectionItem.quantity_remaining }, "cost": collectionItem.is_free ? "Free" : (collectionItem.total_cost == null ? collectionItem.ticket_price : collectionItem.total_cost.display), "status": { "status_is_sold_out": collectionItem.status_is_sold_out, "status_is_ended": collectionItem.status_is_ended, "on_sale_status": collectionItem.on_sale_status }, "dates": { "sales_start": new Date(collectionItem.start_sales).toLocaleFormat(), "sales_end": new Date(collectionItem.end_sales).toLocaleFormat() } }; }

function parseModelItems(model) { return { "is_free": model.is_free, "capacity": model.capacity, "remaining_tickets": model.remaining_tickets, "status": { "status_is_sold_out": model.status_is_sold_out, "status_is_ended": model.status_is_ended }, "dates": { "sales_start": model.first_ticket_sales_start_date, "notification_text": model.not_yet_started_notification_text }, "most_recent_event_update": new Date(model.changed).toLocaleFormat() }; }

function createResultTooltip(data) { var id = "tooltip-custom-event-info"; var tooltip = document.getElementById(id); if(tooltip != null) { // Destroy previous document.body.removeChild(tooltip); }

// Create
tooltip = document.createElement("div");
tooltip.id = id;

tooltip.style.cssText = "width: 40%; max-height: 75%; white-space: pre; overflow-y: auto; " +
    "background-color: #333; color: #EEE; border-radius: 6px; box-shadow: 0px 0px 5px #999; " +
    "position: fixed; left: 1em; top: 6em; z-index: 10001; padding: 1em 2em 1em 1em;";

var closeButton = document.createElement("a");
closeButton.innerHTML = "×";
closeButton.href = "javascript:void(0)";
closeButton.onclick = function() { document.body.removeChild(this.parentElement); };
closeButton.style = "float: right; font-weight: bold; font-size: 2.5em; line-height: 1em;" +
    "position: fixed; left: 40%";

var content = document.createElement("div");
content.innerHTML = data;

tooltip.appendChild(closeButton);
tooltip.appendChild(content);
document.body.appendChild(tooltip);    

}

function run() { checkLocation(); var markup = document.documentElement.innerHTML; var collection = findCollection(markup); var resultString = null;

if(collection == null) {
    var model = findModel(markup);
    var simpleModel = parseModelItems(model);
    resultString = JSON.stringify(simpleModel, null, 2);
    resultString = "<strong>Ticket info not yet available. Try later..." +
        "</strong>\n\n" + resultString;
} else {
    var interestingCollection = [];
    collection.forEach(function(item) {
        interestingCollection.push(parseInteresting(item));
    });

    // Print results
    console.log(interestingCollection); // debug
    resultString = JSON.stringify(interestingCollection, null, 2);
    if(interestingCollection.length > 1) {
        resultString = "<strong>There are several ticket classes..." +
            "</strong>\n\n" + resultString;
    }
}

console.log(resultString);
createResultTooltip(resultString);

}

run(); / Exception: Error: Eventbrite changed something and broke my script. Please let me know. findModel@Scratchpad/1:35:9 run@Scratchpad/1:127:15 @Scratchpad/1:151:1 /

Dalimil commented 7 years ago

Can you give me a URL that was failing? Events whose Eventbrite pages look like this don't currently work: screenshot_2016-10-27_09-31-09

isianonpaper commented 7 years ago

Hi,

So it doesn't currently have a drop down menu like the picture, but it is a multi ticket event.

https://www.eventbrite.com/e/barrel-aged-vietnamese-speedway-stout-mokasida-speedway-stout-bottle-release-tickets-28773797202?aff=es2

I forget the second URL I tried. I will look to add to this list when I get home and can try some others.

I did also try the old version from before the update a week ago--with a 1 instead of 10001--to no avail, fwiw.

EDIT: After digging in further, it is working on older pages that I've run it on before--all single ticket events with the picture header at the top and the "details" button on the right side of the screen.

https://www.eventbrite.com/e/space-trace-bottle-release-tickets-28120857241 https://www.eventbrite.com/e/fundamental-observation-2016-bottle-release-tickets-25589624255# https://www.eventbrite.com/e/leche-borracho-bottle-release-tickets-24635482391#

It's not working on the URL below. This page doesn't have the single header picture like the others, but seems to have an integrated design into the page. It's also missing the "Details" button, with "no ticket information" listed under the Ticket Info section. This makes me hesitant to believe they've uploaded the ticket info to Eventbrite. I may be searching for info that isn't out there yet.

https://www.eventbrite.com/e/barrel-aged-vietnamese-speedway-stout-mokasida-speedway-stout-bottle-release-tickets-28773797202?aff=es2

I'll continue to try periodically--especially once some info populates under Ticket Info--and let you know of the test results.

Edit #2:

I tried it on an old event from the same Seller (with the page format identical to the new sale) and it errored. This seems to be the known issue you've added to the README.

URL https://www.eventbrite.com/e/vietnamese-speedway-barrel-aged-old-numbskull-bottle-sale-tickets-26671154140#

jmiazga commented 6 years ago

I would love to dig into this if someone could provide some links to events that the script doesnt work for.

PjMpire commented 6 years ago

@jmiazga havign trouble getting the info to work on this page https://www.eventbrite.co.uk/e/steelcon-2018-tickets-36060297320#tickets

getting error in firefox developer:

/ Exception: TypeError: (new Date(...)).toLocaleFormat is not a function parseMediatorData/<@Scratchpad/5:32:20 parseMediatorData@Scratchpad/5:15:9 run@Scratchpad/5:88:23 @Scratchpad/5:101:1 /

EDIT: I believe Date.prototype.toLocaleFormat is deprecated

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat

Dalimil commented 6 years ago

@HellboundTKR yeah thanks for reporting this. https://github.com/Dalimil/Eventbrite-Tools/commit/fef96e1ad24385b57a6215239243d364ab836a62 - should be fixed now