dentarg / pynik

:tiger: Internet Relay Chat bot
Other
3 stars 2 forks source link

TitleReader and Instagram #23

Open dentarg opened 8 years ago

dentarg commented 8 years ago

This is of no help:

08:17:53 <.... spuun> https://www.instagram.com/p/BAqirNbwEc0/
08:17:54 <. rufwebot> Instagram

This would be great:

elonmusk: Falcon lands on droneship, but the lockout collet doesn't latch on one the four legs, causing it to tip over post landing. Root cause may have been ice buildup due to condensation from heavy fog at liftoff.

dentarg commented 8 years ago

Instagram has severley limited what API clients can do, needing explicit permission from users, even to get public content, if I understand things correctly (https://www.instagram.com/developer/authorization/, https://www.instagram.com/developer/review/).

Possible solution though, https://www.instagram.com/<user>/media returns nice JSON (e.g. https://www.instagram.com/instagram/media). In that JSON, we could look for the caption belonging to the photo. We have the code from the URL posted (https://www.instagram.com/p/<code>/, but we also need to get the username. We could extract the username from <meta content="See this Instagram video by @elonmusk • 62.4k likes" name="description" /> on the photo page.

dentarg commented 6 years ago

https://www.instagram.com//media returns nice JSON

No more, now 404

dentarg commented 6 years ago

Also, Instagram (tested https://www.instagram.com/p/BAqirNbwEc0/) now triggers exception:

argh <TitleReaderPlugin []> (<type 'exceptions.TypeError'>, TypeError("object of type 'NoneType' has no len()",), <traceback object at 0x7fb54672f3f8>) [('/home/rufwebot/pynik/ircbot.py', 64, 'execute_plugins', 'plugin.__class__.__dict__[trigger](plugin, self, *arguments)'), ('/home/rufwebot/pynik/plugins/title_reader.py', 89, 'on_privmsg', 'bot.tell(target, self.clean(url, title))'), ('/home/rufwebot/pynik/ircbot.py', 112, 'tell', 'return self.client.tell(target, message)'), ('/home/rufwebot/pynik/ircclient/ircclient.py', 91, 'tell', 'if len(string) >= 399:')]