Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rewrite parser, removed requirements

  • Loading branch information...
commit 715838b73a95e683a20c56a56ef1b69fa47754a0 1 parent 91ad452
@ramusus authored
View
5 .travis.yml
@@ -4,9 +4,8 @@ python:
env:
- DJANGO=1.4
install:
- - pip install -qr requirements.txt --use-mirrors
- - pip install -q Django>=$DJANGO --use-mirrors
- - pip install -q . --use-mirrors
+ - pip install Django>=$DJANGO --use-mirrors
+ - pip install . --use-mirrors
script:
- python quicktest.py vkontakte_api
notifications:
View
1  MANIFEST.in
@@ -1,7 +1,6 @@
include README.md
include LICENSE
include MANIFEST.in
-include requirements.txt
include quicktest.py
include settings_test.py
recursive-include vkontakte_api *
View
5 requirements.txt
@@ -1,5 +0,0 @@
-django
-django-annoying
-django-picklefield
-django-oauth-tokens
-vkontakte
View
9 setup.py
@@ -13,7 +13,14 @@
packages=find_packages(),
include_package_data=True,
zip_safe=False, # because we're including media that Django needs
- install_requires=[r.strip() for r in open('requirements.txt').readlines()],
+ install_requires=[
+ 'django',
+ 'django-annoying',
+ 'django-picklefield',
+ 'django-oauth-tokens',
+ 'vkontakte',
+ 'simplejson',
+ ],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
View
4 vkontakte_api/__init__.py
@@ -1,2 +1,2 @@
-VERSION = (0, 3, 6)
-__version__ = '.'.join(map(str, VERSION))
+VERSION = (0, 3, 7)
+__version__ = '.'.join(map(str, VERSION))
View
4 vkontakte_api/models.py
@@ -30,7 +30,7 @@ def __init__(self, methods=None, remote_pk=None, *args, **kwargs):
def get_by_url(self, url):
'''
- Return vkonakte group by group url
+ Return vkonakte object by url
'''
m = re.findall(r'(?:http://)?vk.com/(.+)/?', url)
if not len(m):
@@ -40,7 +40,7 @@ def get_by_url(self, url):
def get_by_slug(self, slug):
'''
- Return User of Group by slug
+ Return User, Group, Application by slug
'''
try:
assert self.model.slug_prefix and slug.startswith(self.model.slug_prefix)
View
22 vkontakte_api/parser.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from BeautifulSoup import BeautifulSoup
+import simplejson as json
import requests
class VkontakteParseError(Exception):
@@ -19,12 +20,21 @@ def html(self):
# fix parsing html for audio tags in http://vk.com/wall-16297716_87985, http://vk.com/wall-16297716_182282?reply=182342
content = content.replace('<!-- ->->','').replace('<!-- -->','')
- start = content.find('<div')
- if '<!>' in content:
- stop = content.find('<!>', start)
- else:
- stop = len(content)
- return content[start:stop]
+ parts = content.split('<!>')
+
+ for part in parts[5:]:
+ if part[:4] == '<div':
+ content = part
+ break
+
+ # concatenate preload container
+ for part in parts[6:]:
+ if part[:7] == '<!json>' and 'preload' in part:
+ data = json.loads(part.replace('<!json>', ''))
+ content += data['preload'][0]
+ break
+
+ return content
@property
def content_bs(self):
Please sign in to comment.
Something went wrong with that request. Please try again.