A question regarding my next plugin

General Discussion
  • GNU/Linux

    @a_5mith, results in that returned data set is an Array, so you'll have to iterate through it (or cheap out and just look at the first array index):

    returnData = {
        results: {
            uri: results[0].uri,
            thumbnail: results[0].thumb,
            catno: results[0].catno,
            title: results[0].title,
            style: results[0].style,
            label: results[0].label,
            year: results[0].year

    ... maybe?

    Edit: Wow, that was fast.

  • @julian

    Edit: Wow, that was fast.

    Pushbullet for Firefox opens the tab automatically. 😆

    Will give it a go. 🙂

  • Right, Birthdays over now (after 3 days) and I'm back on Plugin Development. 😆

    SyntaxError: Unexpected token
    at Object.parse (native)
    at Request._callback (/home/a_5mith/35hz/node_modules/nodebb-plugin-discogs/index.js:84:33)
    at Request.self.callback (/home/a_5mith/35hz/node_modules/nodebb-plugin-discogs/node_modules/request/request.js:123:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/home/a_5mith/35hz/node_modules/nodebb-plugin-discogs/node_modules/request/request.js:1047:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/a_5mith/35hz/node_modules/nodebb-plugin-discogs/node_modules/request/request.js:998:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:929:16
    at process._tickDomainCallback (node.js:463:13)

    84:33 corresponds to the parse in callback(null, JSON.parse(body)),

  • Means your JSON is malformed, perhaps do a console.log(body) and try and find if you're missing a comma somewhere (maybe http://jsonlint.com may help you in that respect)

    EDIT: birthday? yours? 😛 🍰

  • @psychobunny Yeah, turned 23 on the 25th. 😆 🎂

    Right, after a few hours, I'd accidently Ctrl K'd a line out that defines the results var... :shakes head:

    I'm now getting output back from discogs, however, it's definitely not right, I've thrown it into a pastebin.

  • Right, progress, I've got the pagination part

     {"pagination": {"per_page": 50, "items": 0, "page": 1, "urls": {}                                                                                                                     , "pages": 1}, "results": []}

    However results is just [], which is the bit I need. 😆

    Ok, back at undefined, so would appear @julian's snippet didn't work for me. 😞

  • So, I left this for a week or two, just come back to it to see if I could get it working, checked my console.log and what do you know, I have progress, I now have the output that I need (albeit all of it, not just what I specified)

    {"pagination": {"per_page": 1, "items": 1, "page": 1, "urls": {}, "pages": 1}, "results": [{"style": ["Breaks", "Electro", "Drum n Bass"], "thumb": "http://api.discogs.com/image/R-90-3071347-1314359516.jpeg", "format": ["CDr", "Album", "Promo"], "country": "UK", "barcode": [], "uri": "/Noisia-Split-The-Atom/release/3071347", "community": {"have": 12, "want": 10}, "label": ["Vision Recordings"], "catno": "VSNCD001P", "year": "2010", "genre": ["Electronic"], "title": "Noisia - Split The Atom", "resource_url": "http://api.discogs.com/releases/3071347", "type": "release", "id": 3071347}]}

    So my question now is what would I use to get this into the template file?

    I've done {results.catno} and used @julian's earlier method of looping through, but neither works. Any ideas?

    I only need bits of the info inside results. Not the pagination bit.

  • GNU/Linux
                "Drum n Bass"
                "Vision Recordings"
             "title":"Noisia - Split The Atom",

    Just making it look nice 🙂

    You'll need to work with the values in the results hash then... how come you want the data in the template file, and aren't using a hook to modify the post text like the other plugins?

  • @julian It's a card like the Github Plugin that's used here.

    Users enters a category number, and it gets filled out like this:


  • GNU/Linux

    Oh! *facepalm* RIGHT. I forgot the GitHub embed plugin uses templates.js because I was do used to doing it the derp way (creating HTML in javascript, heh).

    Here is where I pass in the issue data. Notice I am calling appModule.render, which is defined in Embed.init.

    Got a repo I can check out? Would be easier than going through the list of how a template can be done wrong (no offense @psychobunny 😆 )

  • @julian Repo can be found heyarrr

  • GNU/Linux

    Is it up to date, and can I mess around with it? 😄

    Edit: I'm spending my morning uninstalling Apps from my phone because it's just unbearable now 😦 3 minutes to open the keyboard? *REALLY?

  • @julian Yes, and yes. 👍

  • GNU/Linux



  • @julian 😆 I was going a bit psycho changing things until something worked.

  • GNU/Linux

    I think I know what went wrong... standby.

    Edit: K, go for it: https://github.com/a5mith/nodebb-plugin-discogs/pull/2


  • @julian Sweet, thanks a lot Julian, only issue I've got left is the image(also in your screenshot), the api states that to get the image, you must authenticate yourelf.

    I have a consumer key & secret which I believe is all I need, just not sure where to put them. 😆

  • @julian They've recently redone the entire documentation, the bit in question is here

  • GNU/Linux

    There shouldn't be any need to funnel all requests into their OAuth flow, especially since you're doing this server-side. Is there any way for you to generate a token in the Discogs API settings, instead of having to step through and authorize yourself?

Suggested Topics

  • 0 Votes
    5 Posts

  • Some questions :)

    General Discussion
    1 Votes
    81 Posts

  • Any Spoiler plugin ?

    General Discussion
    0 Votes
    4 Posts

  • 0 Votes
    7 Posts

  • SSL Question.

    General Discussion
    0 Votes
    9 Posts

| | | |