Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moo goes cow! #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ before_script:

script:
- "flake8 $(find . -iname '*.py')"
- "nosetests --with-coverage --cover-package=mopidy_vkontakte"
- "coverage run --source=mopidy_vkontakte setup.py test"
- "nosetests --with-coverage --cover-package=mopidy.vkontakte"
- "coverage run --source=mopidy setup.py test"

after_success:
- "coveralls"
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ include .travis.yml
include LICENSE
include MANIFEST.in
include README.rst
include mopidy_vkontakte/ext.conf
include mopidy/vkontakte/default.conf

recursive-include tests *.py
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,37 @@ Project resources
Changelog
=========

v0.3.1 (UNRELEASED)
-------------------
v0.3.1
------
- Fixed the encoding issue

v0.3.0 (UNRELEASED)
-------------------
v0.3.0
------

- Fixed a problem if a client requires folders instead of playlists
- Added search functionality but only if you want to find something in vkontakte but not in you library
- Fixed some small issues

v0.2.0 (UNRELEASED)
-------------------
v0.2.0
------

- Require Mopidy >= 0.18.

- Fixed: ``ext.conf`` was missing from the PyPI package, stopping Mopidy from
working as long as Mopidy-VKontakte is installed.

v0.1.2 (2013-11-27)
-------------------
v0.1.2
------

- FIXED: In some cases your token can be expired and you needed to remove a db file manually.
- Released @ 2013-11-27
- Fixed: In some cases your token can be expired and you needed to remove a db file manually.

v0.1.1 (UNRELEASED)
-------------------
v0.1.1
------

- Code style fixed. Setup a test cover system.

v0.1.0 (UNRELEASED)
-------------------
v0.1.0
------

- Initial release.
1 change: 1 addition & 0 deletions mopidy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import os
Expand All @@ -18,7 +20,7 @@ class Extension(ext.Extension):
version = __version__

def get_default_config(self):
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
conf_file = os.path.join(os.path.dirname(__file__), 'default.conf')
return config.read(conf_file)

def get_config_schema(self):
Expand Down
2 changes: 2 additions & 0 deletions mopidy_vkontakte/actor.py → mopidy/vkontakte/actor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions mopidy/vkontakte/form_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-

from HTMLParser import HTMLParser


class FormParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.url = None
self.params = {}
self.in_form = False
self.form_parsed = False
self.method = 'GET'

def handle_starttag(self, tag, attrs):
tag = tag.lower()
if tag == 'form':
if self.form_parsed:
raise RuntimeError('Second form on page')
if self.in_form:
raise RuntimeError('Already in form')
self.in_form = True
if not self.in_form:
return
attrs = dict((name.lower(), value) for name, value in attrs)
if tag == 'form':
self.url = attrs['action']
if 'method' in attrs:
self.method = attrs['method'].upper()
elif tag == 'input' and 'type' in attrs and 'name' in attrs:
if attrs['type'] in ['hidden', 'text', 'password']:
self.params[attrs['name']] = attrs['value'] if 'value' \
in attrs else ''

def handle_endtag(self, tag):
tag = tag.lower()
if tag == 'form':
if not self.in_form:
raise RuntimeError('Unexpected end of <form>')
self.in_form = False
self.form_parsed = True
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging

from mopidy import backend
from mopidy.models import Playlist, Track, Artist
from urllib import unquote

logger = logging.getLogger(__name__)


Expand All @@ -19,7 +21,7 @@ def __init__(self, *args, **kwargs):
self.refresh()

def create(self, name):
print('Playlist create')
logger.debug('Playlist create')

pass

Expand Down
45 changes: 4 additions & 41 deletions mopidy_vkontakte/session.py → mopidy/vkontakte/session.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,22 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging

import os
import json
import time
import shelve
import urllib
import urllib2
import cookielib

from urllib import urlencode
from urlparse import urlparse
from HTMLParser import HTMLParser

logger = logging.getLogger(__name__)
from mopidy.vkontakte.form_parser import FormParser
import os


class FormParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.url = None
self.params = {}
self.in_form = False
self.form_parsed = False
self.method = 'GET'

def handle_starttag(self, tag, attrs):
tag = tag.lower()
if tag == 'form':
if self.form_parsed:
raise RuntimeError('Second form on page')
if self.in_form:
raise RuntimeError('Already in form')
self.in_form = True
if not self.in_form:
return
attrs = dict((name.lower(), value) for name, value in attrs)
if tag == 'form':
self.url = attrs['action']
if 'method' in attrs:
self.method = attrs['method'].upper()
elif tag == 'input' and 'type' in attrs and 'name' in attrs:
if attrs['type'] in ['hidden', 'text', 'password']:
self.params[attrs['name']] = attrs['value'] if 'value' \
in attrs else ''

def handle_endtag(self, tag):
tag = tag.lower()
if tag == 'form':
if not self.in_form:
raise RuntimeError('Unexpected end of <form>')
self.in_form = False
self.form_parsed = True
logger = logging.getLogger(__name__)


class VKSession(object):
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools
mopidy >= 0.18
pykka >= 1.1
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ def get_version(filename):
return metadata['version']


def get_requirements():
with open('requirements.txt', 'r') as f:
return [l.rstrip() for l in f.readlines()]


def get_test_requirements():
with open('test-requirements.txt', 'r') as f:
return [l.rstrip() for l in f.readlines()]

setup(
name='Mopidy-VKontakte',
version=get_version('mopidy_vkontakte/__init__.py'),
version=get_version('mopidy/vkontakte/__init__.py'),
url='https://github.com/sibuser/mopidy-vkontakte',
license='Apache License, Version 2.0',
author='Alexey Ulyanov',
Expand All @@ -23,19 +32,12 @@ def get_version(filename):
packages=find_packages(exclude=['tests', 'tests.*']),
zip_safe=False,
include_package_data=True,
install_requires=[
'setuptools',
'Mopidy >= 0.18',
'Pykka >= 1.1',
],
install_requires=get_requirements(),
test_suite='nose.collector',
tests_require=[
'nose',
'mock >= 1.0',
],
tests_require=get_test_requirements(),
entry_points={
'mopidy.ext': [
'vkontakte = mopidy_vkontakte:Extension',
'vkontakte = mopidy.vkontakte:Extension',
],
},
classifiers=[
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nose
mock >= 1.0
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
4 changes: 3 additions & 1 deletion tests/test_extension.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import mock
import unittest

from mopidy_vkontakte import Extension, actor as backend_lib
from mopidy.vkontakte import Extension, actor as backend_lib


class ExtensionTest(unittest.TestCase):
Expand Down