Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DiSonDS committed Oct 15, 2018
0 parents commit ba36765
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

.idea
46 changes: 46 additions & 0 deletions lastfm2vkstatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pylast
import vk_api
import time
import sys
from settings import *


def main():

# Lastfm init
network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=API_SECRET,
username=USERNAME, password_hash=pylast.md5(PASSWORD))

lastfm = pylast.User("", network)

# VK init
vk_session = vk_api.VkApi(token=VK_USER_TOKEN)
vk = vk_session.get_api()

last_track = ''

while True:
if lastfm:
results = lastfm.get_now_playing()
if not results:
if last_track:
last_track = ''
vk.status.set(text="")
time.sleep(INTERVAL)
continue
if results != last_track:
time_now = time.strftime("%H:%M", time.localtime())
status_text = f"🎧 Last.fm | {results}"
print(f"[{time_now}] {status_text}")
vk.status.set(text=status_text)
last_track = results
time.sleep(INTERVAL)
else:
time.sleep(INTERVAL)
else:
print(f"Can't get user")
sys.exit()


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pylast
vk_api

0 comments on commit ba36765

Please sign in to comment.