Skip to content

Commit 0b58f47

Browse files
committed
Added instagram plugin.
1 parent bb95959 commit 0b58f47

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ Still missing the following resolvers:
142142

143143
* OpengraphResolver()
144144

145-
* InstagramResolver()
146145

147146
I have no plans to implement a 9gag resolver.
148147

docs/README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ Still missing the following resolvers:
141141

142142
* OpengraphResolver()
143143

144-
* InstagramResolver()
145144

146145
I have no plans to implement a 9gag resolver.
147146

imageresolver/plugins/instagram.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import re
2+
import os
3+
import requests
4+
import logging
5+
from bs4 import BeautifulSoup
6+
7+
class Plugin:
8+
def get_image(self, url, **kwargs):
9+
if re.search('http(s*):\/\/instagr(\.am|am\.com)\/p\/([^\/]+)', url):
10+
logger = logging.getLogger('ImageResolver')
11+
logger.debug('Resolving using plugin ' + str(os.path.basename(__file__)) + ' ' + str(url))
12+
r = requests.get(url)
13+
if r.status_code == 200:
14+
soup = BeautifulSoup(r.text)
15+
tag = soup.find('meta',{'property':'og:image'})
16+
if tag:
17+
return tag['content']
18+
return None

0 commit comments

Comments
 (0)