Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2ba8a48ac | |||
| 1530de3188 | |||
| 2d235c0577 | |||
| b0eb58953b | |||
| 7309181fed | |||
| 971fee5b4b | |||
| 920a9180c8 | |||
| d568a377f0 | |||
| 3851624dd7 | |||
| 8c865fe008 | |||
| 572dbf7a88 | |||
| 7addd50577 | |||
| cd5dc25642 | |||
| 9c2355978e | |||
| 4b9b785e50 | |||
| 050b2b9d77 | |||
| d12cca304f | |||
| 8603bbd5cb | |||
| 749e74a54c | |||
| 7b3692ef7b | |||
| c49f6a1740 | |||
| 1d813e4643 |
53
PROJECT.org
53
PROJECT.org
@ -92,7 +92,7 @@ fetching and simple saving.
|
|||||||
:LOGBOOK:
|
:LOGBOOK:
|
||||||
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
|
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
|
||||||
:END:
|
:END:
|
||||||
* Backlog [4/27]
|
* Backlog [0/19]
|
||||||
** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles:
|
** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles:
|
||||||
** TODO [#C] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement:
|
** TODO [#C] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
@ -414,7 +414,6 @@ Could be as simple as a JSON form on the scrobble detail page (do I have have on
|
|||||||
** TODO [#B] Add webdav syncing to retroarch imports :vrobbler:videogames:webdav:feature:project:personal:
|
** TODO [#B] Add webdav syncing to retroarch imports :vrobbler:videogames:webdav:feature:project:personal:
|
||||||
** TODO [#B] Add CSV endpoint for book scrobbles that LibraryThing can ingest :personal:project:books:feature:export:
|
** TODO [#B] Add CSV endpoint for book scrobbles that LibraryThing can ingest :personal:project:books:feature:export:
|
||||||
https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-library-thing-can-ingest-6X7QPMRp265xMXqg#comment-6X7QrXq6gJjMP4hg
|
https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-library-thing-can-ingest-6X7QPMRp265xMXqg#comment-6X7QrXq6gJjMP4hg
|
||||||
** TODO [#B] Add youtube link in place of IMDB on video detail page :vrobbler:feature:videos:personal:project:
|
|
||||||
** TODO [#B] Fix PuzzleLogData has no attribute form :vrobbler:puzzles:personal:project:logdata:
|
** TODO [#B] Fix PuzzleLogData has no attribute form :vrobbler:puzzles:personal:project:logdata:
|
||||||
** TODO [#B] Scrape ComicBookRoundUp ratings for comic book metadata :vrobbler:books:feature:comicbook:personal:project:
|
** TODO [#B] Scrape ComicBookRoundUp ratings for comic book metadata :vrobbler:books:feature:comicbook:personal:project:
|
||||||
|
|
||||||
@ -422,7 +421,12 @@ https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-li
|
|||||||
|
|
||||||
As an example https://comicbookroundup.com/comic-books/reviews/humanoids-publishing/the-history-of-science-fiction
|
As an example https://comicbookroundup.com/comic-books/reviews/humanoids-publishing/the-history-of-science-fiction
|
||||||
** TODO [#B] Add PuzzleLogData class with with_people and completed :vrobbler:feature:puzzles:logdata:personal:project:
|
** TODO [#B] Add PuzzleLogData class with with_people and completed :vrobbler:feature:puzzles:logdata:personal:project:
|
||||||
** TODO [#A] Tasks from org-mode should properly update notes and leave them out of the body :vrobbler:bug:tasks:
|
** TODO [#A] Fix raw text webpage title not truncating to 254 chars :vrobbler:personal:bug:webpages:
|
||||||
|
|
||||||
|
- Note taken on [2025-09-30 Tue 09:33]
|
||||||
|
|
||||||
|
This may have already been resolved ... need to just confirm it.
|
||||||
|
** TODO [#A] Find page numbers for comic books from ComicVine :vrobbler:feature:books:personal:project:
|
||||||
** TODO [#A] Fix koreader scrobble imports to use DST properly :vrobbler:personal:bug:books:imports:
|
** TODO [#A] Fix koreader scrobble imports to use DST properly :vrobbler:personal:bug:books:imports:
|
||||||
|
|
||||||
- Note taken on [2025-09-25 Thu 10:37] \\
|
- Note taken on [2025-09-25 Thu 10:37] \\
|
||||||
@ -437,15 +441,42 @@ https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-li
|
|||||||
an hour for part of the year. Also, we'd need to adjust any old scrobbles that
|
an hour for part of the year. Also, we'd need to adjust any old scrobbles that
|
||||||
took place with DST off to roll them back by an hour.
|
took place with DST off to roll them back by an hour.
|
||||||
|
|
||||||
** TODO [#A] Allow scrobbling from the Food list page's start links :vrobbler:bug:food:scrobbling:personal:project:
|
* Version 37.0 [4/4]
|
||||||
|
** DONE [#A] Tasks from org-mode should properly update notes and leave them out of the body :vrobbler:bug:tasks:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: c8410001-dbb7-1536-bd89-9784189e058f
|
||||||
|
:END:
|
||||||
|
** DONE [#A] Allow scrobbling from the Food list page's start links :vrobbler:bug:food:scrobbling:personal:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 00f99f60-ac00-6cde-311d-c31f41a01353
|
||||||
|
:END:
|
||||||
https://life.lab.unbl.ink/scrobble/e39779c8-62a5-46a6-bdef-fb7662810dc6/start/
|
https://life.lab.unbl.ink/scrobble/e39779c8-62a5-46a6-bdef-fb7662810dc6/start/
|
||||||
** TODO [#A] Puzzles (and all longplays) should have a "Completed?" column on their detail page :vrobbler:bug:puzzles:personal:project:
|
** DONE [#B] Food scrobbles should inherit calories from obj if missing :vrobbler:feature:food:personal:project:
|
||||||
** TODO [#A] Fix raw text webpage title not truncating to 254 chars :vrobbler:personal:bug:webpages:
|
:PROPERTIES:
|
||||||
|
:ID: 3322ff69-4252-db65-36b3-fae56c1b9327
|
||||||
- Note taken on [2025-09-30 Tue 09:33]
|
:END:
|
||||||
|
** DONE [#A] Puzzles (and all longplays) should have a "Completed?" column on their detail page :vrobbler:bug:puzzles:personal:project:
|
||||||
This may have already been resolved ... need to just confirm it.
|
:PROPERTIES:
|
||||||
** TODO [#A] Find page numbers for comic books from ComicVine :vrobbler:feature:books:personal:project:
|
:ID: e3e49a9a-67d2-8ad8-1114-6f05effee9b7
|
||||||
|
:END:
|
||||||
|
* Version 36.0 [1/1]
|
||||||
|
** DONE [#A] Refactor how videos are scrobbled :vrobbler:vidoes:feature:personal:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 6034a11d-5376-994d-9a4b-e1640e258cfa
|
||||||
|
:END:
|
||||||
|
* Version 35.0 [3/3]
|
||||||
|
** DONE [#B] Add youtube link in place of IMDB on video detail page :vrobbler:feature:videos:personal:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 84064bd6-2258-a4de-f048-b131db9465c9
|
||||||
|
:END:
|
||||||
|
** DONE [#B] Add missing API lookups to resolve broken scrobbles endpoint :vrobbler:feature:api:scrobbles:personal:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 0f668a54-f587-3b17-353e-3a56969d3a82
|
||||||
|
:END:
|
||||||
|
** DONE [#A] IMDB lookups are not working :vrobbler:bug:videos:personal:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: d1ba1ca1-509b-13a9-1307-b2dc94a2eafe
|
||||||
|
:END:
|
||||||
* Version 34.0 [4/4]
|
* Version 34.0 [4/4]
|
||||||
** DONE [#A] Use bgg-api for BoardGameGeek lookups :vrobbler:feature:boardgames:personal:project:
|
** DONE [#A] Use bgg-api for BoardGameGeek lookups :vrobbler:feature:boardgames:personal:project:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
|||||||
5172
poetry.lock
generated
5172
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ description = ""
|
|||||||
authors = ["Colin Powell <colin@unbl.ink>"]
|
authors = ["Colin Powell <colin@unbl.ink>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = ">=3.9,<3.12"
|
python = ">=3.11,<3.14"
|
||||||
Django = "^4.0.3"
|
Django = "^4.0.3"
|
||||||
django-extensions = "^3.1.5"
|
django-extensions = "^3.1.5"
|
||||||
python-dateutil = "^2.8.2"
|
python-dateutil = "^2.8.2"
|
||||||
@ -16,8 +16,8 @@ httpx = "<=0.27.2"
|
|||||||
djangorestframework = "^3.13.1"
|
djangorestframework = "^3.13.1"
|
||||||
Markdown = "^3.3.6"
|
Markdown = "^3.3.6"
|
||||||
django-filter = "^21.1"
|
django-filter = "^21.1"
|
||||||
Pillow = "^9.0.1"
|
Pillow = "^10.0.0"
|
||||||
psycopg2 = "^2.9.3"
|
psycopg2 = "2.9.10"
|
||||||
dj-database-url = "^0.5.0"
|
dj-database-url = "^0.5.0"
|
||||||
django-mathfilters = "^1.0.0"
|
django-mathfilters = "^1.0.0"
|
||||||
django-allauth = "^0.50.0"
|
django-allauth = "^0.50.0"
|
||||||
@ -28,7 +28,7 @@ django-markdownify = "^0.9.1"
|
|||||||
gunicorn = "^20.1.0"
|
gunicorn = "^20.1.0"
|
||||||
django-simple-history = "^3.1.1"
|
django-simple-history = "^3.1.1"
|
||||||
musicbrainzngs = "^0.7.1"
|
musicbrainzngs = "^0.7.1"
|
||||||
cinemagoer = "^2022.12.27"
|
cinemagoerng = {git = "https://github.com/cinemagoer/cinemagoerng"}
|
||||||
pysportsdb = "^0.1.0"
|
pysportsdb = "^0.1.0"
|
||||||
pytz = "^2022.7.1"
|
pytz = "^2022.7.1"
|
||||||
django-redis = "^5.2.0"
|
django-redis = "^5.2.0"
|
||||||
@ -41,11 +41,11 @@ beautifulsoup4 = "^4.11.2"
|
|||||||
django-storages = "^1.13.2"
|
django-storages = "^1.13.2"
|
||||||
stream-sqlite = "^0.0.41"
|
stream-sqlite = "^0.0.41"
|
||||||
ipython = "^8.14.0"
|
ipython = "^8.14.0"
|
||||||
pendulum = "^2.1.2"
|
pendulum = "^3"
|
||||||
trafilatura = "^1.6.3"
|
trafilatura = "^1.6.3"
|
||||||
django-imagekit = "^5.0.0"
|
django-imagekit = "^5.0.0"
|
||||||
thefuzz = "^0.22.1"
|
thefuzz = "^0.22.1"
|
||||||
dataclass-wizard = "0.22.0"
|
dataclass-wizard = "^0.35.0"
|
||||||
webdavclient3 = "^3.14.6"
|
webdavclient3 = "^3.14.6"
|
||||||
boto3 = "^1.35.37"
|
boto3 = "^1.35.37"
|
||||||
urllib3 = "<2"
|
urllib3 = "<2"
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
from videos.sources.imdb import lookup_video_from_imdb
|
from videos.sources.imdb import lookup_video_from_imdb
|
||||||
|
|
||||||
|
def test_lookup_imdb_without_tt():
|
||||||
def test_lookup_imdb():
|
|
||||||
metadata = lookup_video_from_imdb("8946378")
|
metadata = lookup_video_from_imdb("8946378")
|
||||||
|
print(metadata.__dict__)
|
||||||
|
assert not metadata.imdb_id
|
||||||
|
|
||||||
|
def test_lookup_imdb_with_tt():
|
||||||
|
metadata = lookup_video_from_imdb("tt8946378")
|
||||||
assert metadata.title == "Knives Out"
|
assert metadata.title == "Knives Out"
|
||||||
|
|||||||
0
vrobbler/apps/beers/api/__init__.py
Normal file
0
vrobbler/apps/beers/api/__init__.py
Normal file
18
vrobbler/apps/beers/api/serializers.py
Normal file
18
vrobbler/apps/beers/api/serializers.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from beers.models import Beer, BeerProducer, BeerStyle
|
||||||
|
|
||||||
|
|
||||||
|
class BeerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Beer
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class BeerProducerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = BeerProducer
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class BeerStyleSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = BeerStyle
|
||||||
|
fields = "__all__"
|
||||||
19
vrobbler/apps/beers/api/views.py
Normal file
19
vrobbler/apps/beers/api/views.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
from beers.api import serializers
|
||||||
|
from beers import models
|
||||||
|
|
||||||
|
|
||||||
|
class BeerViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Beer.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BeerSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
class BeerProducerViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BeerProducer.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BeerProducerSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
class BeerStyleViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BeerStyle.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BeerStyleSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
22
vrobbler/apps/boardgames/api/serializers.py
Normal file
22
vrobbler/apps/boardgames/api/serializers.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from boardgames import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
class BoardGameDesignerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.BoardGameDesigner
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class BoardGamePublisherSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.BoardGamePublisher
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class BoardGameLocationSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.BoardGameLocation
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class BoardGameSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.BoardGame
|
||||||
|
fields = "__all__"
|
||||||
28
vrobbler/apps/boardgames/api/views.py
Normal file
28
vrobbler/apps/boardgames/api/views.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from boardgames.api import serializers
|
||||||
|
from boardgames import models
|
||||||
|
|
||||||
|
|
||||||
|
class BoardGameDesignerViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BoardGameDesigner.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BoardGameDesignerSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class BoardGamePublisherViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BoardGamePublisher.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BoardGamePublisherSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class BoardGameLocationViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BoardGameLocation.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BoardGameLocationSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class BoardGameViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.BoardGame.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.BoardGameSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
@ -1,19 +1,16 @@
|
|||||||
from rest_framework import permissions, viewsets
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
from books.api.serializers import (
|
from books.api import serializers
|
||||||
AuthorSerializer,
|
from books import models
|
||||||
BookSerializer,
|
|
||||||
)
|
|
||||||
from books.models import Author, Book
|
|
||||||
|
|
||||||
|
|
||||||
class AuthorViewSet(viewsets.ModelViewSet):
|
class AuthorViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Author.objects.all().order_by("-created")
|
queryset = models.Author.objects.all().order_by("-created")
|
||||||
serializer_class = AuthorSerializer
|
serializer_class = serializers.AuthorSerializer
|
||||||
permission_classes = [permissions.IsAuthenticated]
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
class BookViewSet(viewsets.ModelViewSet):
|
class BookViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Book.objects.all().order_by("-created")
|
queryset = models.Book.objects.all().order_by("-created")
|
||||||
serializer_class = BookSerializer
|
serializer_class = serializers.BookSerializer
|
||||||
permission_classes = [permissions.IsAuthenticated]
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|||||||
@ -286,11 +286,11 @@ def build_scrobbles_from_book_map(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Adjust for Daylight Saving Time
|
# Adjust for Daylight Saving Time
|
||||||
if timestamp.dst() == timedelta(
|
#if timestamp.dst() == timedelta(
|
||||||
0
|
# 0
|
||||||
) or stop_timestamp.dst() == timedelta(0):
|
#) or stop_timestamp.dst() == timedelta(0):
|
||||||
timestamp = timestamp - timedelta(hours=1)
|
# timestamp = timestamp - timedelta(hours=1)
|
||||||
stop_timestamp = stop_timestamp - timedelta(hours=1)
|
# stop_timestamp = stop_timestamp - timedelta(hours=1)
|
||||||
|
|
||||||
scrobble = Scrobble.objects.filter(
|
scrobble = Scrobble.objects.filter(
|
||||||
timestamp=timestamp,
|
timestamp=timestamp,
|
||||||
|
|||||||
@ -153,8 +153,8 @@ class Book(LongPlayScrobblableMixin):
|
|||||||
comicvine_id = models.CharField(max_length=255, **BNULL)
|
comicvine_id = models.CharField(max_length=255, **BNULL)
|
||||||
readcomics_url = models.CharField(max_length=255, **BNULL)
|
readcomics_url = models.CharField(max_length=255, **BNULL)
|
||||||
next_readcomics_url = models.CharField(max_length=255, **BNULL)
|
next_readcomics_url = models.CharField(max_length=255, **BNULL)
|
||||||
issue_number = models.IntegerField(max_length=5, **BNULL)
|
issue_number = models.IntegerField(**BNULL)
|
||||||
volume_number = models.IntegerField(max_length=5, **BNULL)
|
volume_number = models.IntegerField(**BNULL)
|
||||||
# OpenLibrary
|
# OpenLibrary
|
||||||
openlibrary_id = models.CharField(max_length=255, **BNULL)
|
openlibrary_id = models.CharField(max_length=255, **BNULL)
|
||||||
cover = models.ImageField(upload_to="books/covers/", **BNULL)
|
cover = models.ImageField(upload_to="books/covers/", **BNULL)
|
||||||
|
|||||||
0
vrobbler/apps/bricksets/api/__init__.py
Normal file
0
vrobbler/apps/bricksets/api/__init__.py
Normal file
8
vrobbler/apps/bricksets/api/serializers.py
Normal file
8
vrobbler/apps/bricksets/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from bricksets.models import BrickSet
|
||||||
|
|
||||||
|
|
||||||
|
class BrickSetSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = BrickSet
|
||||||
|
fields = "__all__"
|
||||||
9
vrobbler/apps/bricksets/api/views.py
Normal file
9
vrobbler/apps/bricksets/api/views.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
from bricksets.api.serializers import BrickSetSerializer
|
||||||
|
from bricksets.models import BrickSet
|
||||||
|
|
||||||
|
|
||||||
|
class BrickSetViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = BrickSet.objects.all().order_by("-created")
|
||||||
|
serializer_class = BrickSetSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
0
vrobbler/apps/foods/api/__init__.py
Normal file
0
vrobbler/apps/foods/api/__init__.py
Normal file
14
vrobbler/apps/foods/api/serializers.py
Normal file
14
vrobbler/apps/foods/api/serializers.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from foods import models
|
||||||
|
|
||||||
|
|
||||||
|
class FoodCategorySerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.FoodCategory
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
|
class FoodSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Food
|
||||||
|
fields = "__all__"
|
||||||
21
vrobbler/apps/foods/api/views.py
Normal file
21
vrobbler/apps/foods/api/views.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
from foods.api.serializers import (
|
||||||
|
FoodSerializer,
|
||||||
|
FoodCategorySerializer,
|
||||||
|
)
|
||||||
|
from foods.models import (
|
||||||
|
FoodCategory,
|
||||||
|
Food,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class FoodCategoryViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = FoodCategory.objects.all().order_by("-created")
|
||||||
|
serializer_class = FoodCategorySerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class FoodViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Food.objects.all().order_by("-created")
|
||||||
|
serializer_class = FoodSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
@ -18,7 +18,6 @@ BNULL = {"blank": True, "null": True}
|
|||||||
class FoodLogData(BaseLogData, WithPeopleLogData):
|
class FoodLogData(BaseLogData, WithPeopleLogData):
|
||||||
calories: Optional[int] = None
|
calories: Optional[int] = None
|
||||||
meal: Optional[str] = None
|
meal: Optional[str] = None
|
||||||
rating: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class FoodCategory(TimeStampedModel):
|
class FoodCategory(TimeStampedModel):
|
||||||
|
|||||||
8
vrobbler/apps/lifeevents/api/serializers.py
Normal file
8
vrobbler/apps/lifeevents/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from lifeevents.models import LifeEvent
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class LifeEventSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = LifeEvent
|
||||||
|
fields = "__all__"
|
||||||
10
vrobbler/apps/lifeevents/api/views.py
Normal file
10
vrobbler/apps/lifeevents/api/views.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from lifeevents.api import serializers
|
||||||
|
from lifeevents import models
|
||||||
|
|
||||||
|
|
||||||
|
class LifeEventViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.LifeEvent.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.LifeEventSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
8
vrobbler/apps/locations/api/serializers.py
Normal file
8
vrobbler/apps/locations/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from locations import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class GeoLocationSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.GeoLocation
|
||||||
|
fields = "__all__"
|
||||||
9
vrobbler/apps/locations/api/views.py
Normal file
9
vrobbler/apps/locations/api/views.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from locations.api import serializers
|
||||||
|
from locations import models
|
||||||
|
|
||||||
|
class GeoLocationViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.GeoLocation.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.GeoLocationSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
0
vrobbler/apps/moods/api/__init__.py
Normal file
0
vrobbler/apps/moods/api/__init__.py
Normal file
8
vrobbler/apps/moods/api/serializers.py
Normal file
8
vrobbler/apps/moods/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from moods.models import Mood
|
||||||
|
|
||||||
|
|
||||||
|
class MoodSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Mood
|
||||||
|
fields = "__all__"
|
||||||
9
vrobbler/apps/moods/api/views.py
Normal file
9
vrobbler/apps/moods/api/views.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
from moods.api.serializers import MoodSerializer
|
||||||
|
from moods.models import Mood
|
||||||
|
|
||||||
|
|
||||||
|
class MoodViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Mood.objects.all().order_by("-created")
|
||||||
|
serializer_class = MoodSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
17
vrobbler/apps/podcasts/api/serializers.py
Normal file
17
vrobbler/apps/podcasts/api/serializers.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from podcasts import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
class ProducerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Producer
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class PodcastEpisodeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.PodcastEpisode
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class PodcastSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Podcast
|
||||||
|
fields = "__all__"
|
||||||
20
vrobbler/apps/podcasts/api/views.py
Normal file
20
vrobbler/apps/podcasts/api/views.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from podcasts.api import serializers
|
||||||
|
from podcasts import models
|
||||||
|
|
||||||
|
|
||||||
|
class ProducerViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Producer.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.ProducerSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
class PodcastViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Podcast.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.PodcastSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
class PodcastEpisodeViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.PodcastEpisode.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.PodcastEpisodeSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
12
vrobbler/apps/puzzles/api/serializers.py
Normal file
12
vrobbler/apps/puzzles/api/serializers.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from puzzles import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
class PuzzleManufacturerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.PuzzleManufacturer
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
class PuzzleSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Puzzle
|
||||||
|
fields = "__all__"
|
||||||
15
vrobbler/apps/puzzles/api/views.py
Normal file
15
vrobbler/apps/puzzles/api/views.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from puzzles.api import serializers
|
||||||
|
from puzzles import models
|
||||||
|
|
||||||
|
class PuzzleManufacturerViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.PuzzleManufacturer.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.PuzzleManufacturerSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class PuzzleViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Puzzle.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.PuzzleSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
@ -11,17 +11,15 @@ from django_extensions.db.models import TimeStampedModel
|
|||||||
from imagekit.models import ImageSpecField
|
from imagekit.models import ImageSpecField
|
||||||
from imagekit.processors import ResizeToFit
|
from imagekit.processors import ResizeToFit
|
||||||
from puzzles.sources import ipdb
|
from puzzles.sources import ipdb
|
||||||
from scrobbles.dataclasses import JSONDataclass
|
from scrobbles.dataclasses import BaseLogData, WithPeopleLogData, LongPlayLogData
|
||||||
from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
|
from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
|
||||||
|
|
||||||
BNULL = {"blank": True, "null": True}
|
BNULL = {"blank": True, "null": True}
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PuzzleLogData(JSONDataclass):
|
class PuzzleLogData(BaseLogData, WithPeopleLogData, LongPlayLogData):
|
||||||
with_people: Optional[int] = None
|
|
||||||
rating: Optional[str] = None
|
rating: Optional[str] = None
|
||||||
notes: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class PuzzleManufacturer(TimeStampedModel):
|
class PuzzleManufacturer(TimeStampedModel):
|
||||||
|
|||||||
@ -13,7 +13,10 @@ User = get_user_model()
|
|||||||
|
|
||||||
class ScrobbleLogDataEncoder(json.JSONEncoder):
|
class ScrobbleLogDataEncoder(json.JSONEncoder):
|
||||||
def default(self, o):
|
def default(self, o):
|
||||||
return o.__dict__
|
try:
|
||||||
|
return o.__dict__
|
||||||
|
except AttributeError:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class ScrobbleLogDataDecoder(json.JSONDecoder):
|
class ScrobbleLogDataDecoder(json.JSONDecoder):
|
||||||
|
|||||||
@ -77,11 +77,8 @@ def form_from_dataclass(dataclass):
|
|||||||
override_fields = {}
|
override_fields = {}
|
||||||
for klass in dataclass.mro():
|
for klass in dataclass.mro():
|
||||||
if hasattr(klass, "override_fields"):
|
if hasattr(klass, "override_fields"):
|
||||||
print(klass, ": ", klass.override_fields())
|
|
||||||
override_fields.update(klass.override_fields())
|
override_fields.update(klass.override_fields())
|
||||||
print("overrides: ", override_fields)
|
|
||||||
for f in fields(dataclass):
|
for f in fields(dataclass):
|
||||||
print(f)
|
|
||||||
if f.name in override_fields:
|
if f.name in override_fields:
|
||||||
form_fields[f.name] = override_fields[f.name]
|
form_fields[f.name] = override_fields[f.name]
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -22,7 +22,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django_extensions.db.models import TimeStampedModel
|
from django_extensions.db.models import TimeStampedModel
|
||||||
from foods.models import Food
|
from foods.models import Food, FoodLogData
|
||||||
from imagekit.models import ImageSpecField
|
from imagekit.models import ImageSpecField
|
||||||
from imagekit.processors import ResizeToFit
|
from imagekit.processors import ResizeToFit
|
||||||
from lifeevents.models import LifeEvent
|
from lifeevents.models import LifeEvent
|
||||||
@ -1210,6 +1210,9 @@ class Scrobble(TimeStampedModel):
|
|||||||
"source": source,
|
"source": source,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
if mtype == cls.MediaType.FOOD and not scrobble_data.get("log", {}).get("calories", None):
|
||||||
|
if media.calories:
|
||||||
|
scrobble_data["log"] = FoodLogData(calories=media.calories)
|
||||||
|
|
||||||
scrobble = cls.create(scrobble_data)
|
scrobble = cls.create(scrobble_data)
|
||||||
return scrobble
|
return scrobble
|
||||||
|
|||||||
@ -123,9 +123,8 @@ def jellyfin_scrobble_media(
|
|||||||
/ 10000000
|
/ 10000000
|
||||||
)
|
)
|
||||||
if media_type == Scrobble.MediaType.VIDEO:
|
if media_type == Scrobble.MediaType.VIDEO:
|
||||||
media_obj = Video.get_from_imdb_id(
|
imdb_id = post_data.get("Provider_imdb", "")
|
||||||
post_data.get("Provider_imdb", "").replace("tt", "")
|
media_obj = Video.find_or_create(imdb_id)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
media_obj = Track.find_or_create(
|
media_obj = Track.find_or_create(
|
||||||
title=post_data.get("Name", ""),
|
title=post_data.get("Name", ""),
|
||||||
@ -162,21 +161,16 @@ def jellyfin_scrobble_media(
|
|||||||
def web_scrobbler_scrobble_media(
|
def web_scrobbler_scrobble_media(
|
||||||
youtube_id: str, user_id: int, status: str = "started"
|
youtube_id: str, user_id: int, status: str = "started"
|
||||||
) -> Optional[Scrobble]:
|
) -> Optional[Scrobble]:
|
||||||
video = Video.get_from_youtube_id(youtube_id)
|
video = Video.find_or_create(youtube_id)
|
||||||
return video.scrobble_for_user(user_id, status, source="Web Scrobbler")
|
return video.scrobble_for_user(user_id, status, source="Web Scrobbler")
|
||||||
|
|
||||||
|
|
||||||
def manual_scrobble_video(
|
def manual_scrobble_video(
|
||||||
video_id: str, user_id: int, action: Optional[str] = None
|
video_id: str, user_id: int, source: str = "IMDb", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
if "tt" in video_id:
|
video = Video.find_or_create(video_id)
|
||||||
video = Video.get_from_imdb_id(video_id)
|
|
||||||
|
|
||||||
else:
|
|
||||||
video = Video.get_from_youtube_id(video_id)
|
|
||||||
|
|
||||||
# When manually scrobbling, try finding a source from the series
|
# When manually scrobbling, try finding a source from the series
|
||||||
source = "Vrobbler"
|
|
||||||
if video.tv_series:
|
if video.tv_series:
|
||||||
source = video.tv_series.preferred_source
|
source = video.tv_series.preferred_source
|
||||||
scrobble_dict = {
|
scrobble_dict = {
|
||||||
@ -205,7 +199,7 @@ def manual_scrobble_video(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_event(
|
def manual_scrobble_event(
|
||||||
thesportsdb_id: str, user_id: int, action: Optional[str] = None
|
thesportsdb_id: str, user_id: int, source: str = "TheSportsDB", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
data_dict = lookup_event_from_thesportsdb(thesportsdb_id)
|
data_dict = lookup_event_from_thesportsdb(thesportsdb_id)
|
||||||
|
|
||||||
@ -220,7 +214,7 @@ def manual_scrobble_event(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_video_game(
|
def manual_scrobble_video_game(
|
||||||
hltb_id: str, user_id: int, action: Optional[str] = None
|
hltb_id: str, user_id: int, source: str = "HLTB", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
game = VideoGame.objects.filter(hltb_id=hltb_id).first()
|
game = VideoGame.objects.filter(hltb_id=hltb_id).first()
|
||||||
if not game:
|
if not game:
|
||||||
@ -242,7 +236,7 @@ def manual_scrobble_video_game(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
"long_play_complete": False,
|
"long_play_complete": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,10 +254,9 @@ def manual_scrobble_video_game(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_book(
|
def manual_scrobble_book(
|
||||||
title: str, user_id: int, action: Optional[str] = None
|
title: str, user_id: int, source: str = "Google Books", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
log = {}
|
log = {}
|
||||||
source = "Vrobbler"
|
|
||||||
page = None
|
page = None
|
||||||
url = ""
|
url = ""
|
||||||
|
|
||||||
@ -328,7 +321,7 @@ def manual_scrobble_book(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_board_game(
|
def manual_scrobble_board_game(
|
||||||
bggeek_id: str, user_id: int, action: Optional[str] = None
|
bggeek_id: str, user_id: int, source: str = "BGG", action: Optional[str] = None
|
||||||
) -> Scrobble | None:
|
) -> Scrobble | None:
|
||||||
boardgame = BoardGame.find_or_create(bggeek_id)
|
boardgame = BoardGame.find_or_create(bggeek_id)
|
||||||
|
|
||||||
@ -340,7 +333,7 @@ def manual_scrobble_board_game(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] board game scrobble request received",
|
"[vrobbler-scrobble] board game scrobble request received",
|
||||||
@ -530,7 +523,7 @@ def email_scrobble_board_game(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_from_url(
|
def manual_scrobble_from_url(
|
||||||
url: str, user_id: int, action: Optional[str] = None
|
url: str, user_id: int, source: str = "Vrobbler", action: Optional[str] = None
|
||||||
) -> Scrobble:
|
) -> Scrobble:
|
||||||
"""We have scrobblable media URLs, and then any other webpages that
|
"""We have scrobblable media URLs, and then any other webpages that
|
||||||
we want to scrobble as a media type in and of itself. This checks whether
|
we want to scrobble as a media type in and of itself. This checks whether
|
||||||
@ -564,7 +557,7 @@ def manual_scrobble_from_url(
|
|||||||
item_id = "tt" + str(item_id)
|
item_id = "tt" + str(item_id)
|
||||||
|
|
||||||
scrobble_fn = MANUAL_SCROBBLE_FNS[content_key]
|
scrobble_fn = MANUAL_SCROBBLE_FNS[content_key]
|
||||||
return eval(scrobble_fn)(item_id, user_id, action=action)
|
return eval(scrobble_fn)(item_id, user_id, source=source, action=action)
|
||||||
|
|
||||||
|
|
||||||
def todoist_scrobble_task_finish(
|
def todoist_scrobble_task_finish(
|
||||||
@ -843,9 +836,10 @@ def emacs_scrobble_task(
|
|||||||
return scrobble
|
return scrobble
|
||||||
|
|
||||||
|
|
||||||
def manual_scrobble_task(url: str, user_id: int, action: Optional[str] = None):
|
def manual_scrobble_task(url: str, user_id: int, source: str = "Vrobbler", action: Optional[str] = None):
|
||||||
source_id = re.findall(r"\d+", url)[0]
|
source_id = re.findall(r"\d+", url)[0]
|
||||||
|
|
||||||
|
description = ""
|
||||||
if "todoist" in url:
|
if "todoist" in url:
|
||||||
source = "Todoist"
|
source = "Todoist"
|
||||||
title = "Generic Todoist task"
|
title = "Generic Todoist task"
|
||||||
@ -874,7 +868,7 @@ def manual_scrobble_task(url: str, user_id: int, action: Optional[str] = None):
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_webpage(
|
def manual_scrobble_webpage(
|
||||||
url: str, user_id: int, action: Optional[str] = None
|
url: str, user_id: int, source: str = "Bookmarklet", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
webpage = WebPage.find_or_create({"url": url})
|
webpage = WebPage.find_or_create({"url": url})
|
||||||
|
|
||||||
@ -882,7 +876,7 @@ def manual_scrobble_webpage(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] webpage scrobble request received",
|
"[vrobbler-scrobble] webpage scrobble request received",
|
||||||
@ -1001,7 +995,7 @@ def web_scrobbler_scrobble_video_or_song(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_beer(
|
def manual_scrobble_beer(
|
||||||
untappd_id: str, user_id: int, action: Optional[str] = None
|
untappd_id: str, user_id: int, source: str = "Untappd", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
beer = Beer.find_or_create(untappd_id)
|
beer = Beer.find_or_create(untappd_id)
|
||||||
|
|
||||||
@ -1013,7 +1007,7 @@ def manual_scrobble_beer(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] beer scrobble request received",
|
"[vrobbler-scrobble] beer scrobble request received",
|
||||||
@ -1030,7 +1024,7 @@ def manual_scrobble_beer(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_puzzle(
|
def manual_scrobble_puzzle(
|
||||||
ipdb_id: str, user_id: int, action: Optional[str] = None
|
ipdb_id: str, user_id: int, source: str = "IPDb", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
puzzle = Puzzle.find_or_create(ipdb_id)
|
puzzle = Puzzle.find_or_create(ipdb_id)
|
||||||
|
|
||||||
@ -1042,7 +1036,7 @@ def manual_scrobble_puzzle(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[vrobbler-scrobble] puzzle scrobble request received",
|
"[vrobbler-scrobble] puzzle scrobble request received",
|
||||||
@ -1059,7 +1053,7 @@ def manual_scrobble_puzzle(
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_brickset(
|
def manual_scrobble_brickset(
|
||||||
brickset_id: str, user_id: int, action: Optional[str] = None
|
brickset_id: str, user_id: int, source: str = "BrickSet", action: Optional[str] = None
|
||||||
):
|
):
|
||||||
brickset = BrickSet.find_or_create(brickset_id)
|
brickset = BrickSet.find_or_create(brickset_id)
|
||||||
|
|
||||||
@ -1071,7 +1065,7 @@ def manual_scrobble_brickset(
|
|||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"timestamp": timezone.now(),
|
"timestamp": timezone.now(),
|
||||||
"playback_position_seconds": 0,
|
"playback_position_seconds": 0,
|
||||||
"source": "Vrobbler",
|
"source": source,
|
||||||
"log": {"serial_scrobble_id": ""},
|
"log": {"serial_scrobble_id": ""},
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
BIN
vrobbler/apps/scrobbles/static/images/youtube_logo.png
Normal file
BIN
vrobbler/apps/scrobbles/static/images/youtube_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -396,11 +396,12 @@ def get_daily_calories_for_user_by_day(user_id: int, date: date| str) -> int:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
qs = base_scrobble_qs(user_id).filter(day=date)
|
qs = base_scrobble_qs(user_id).filter(day=date)
|
||||||
except AttibuteError as e:
|
agg = qs.aggregate(total_calories=models.Sum("calories_int"))
|
||||||
|
except AttributeError as e:
|
||||||
logger.warning(f"Can't generate calorie total: {e}")
|
logger.warning(f"Can't generate calorie total: {e}")
|
||||||
agg = qs.aggregate(total_calories=models.Sum("calories_int"))
|
agg = {}
|
||||||
|
|
||||||
return agg["total_calories"] or 0
|
return agg.get("total_calories") or 0
|
||||||
|
|
||||||
def get_daily_calorie_dict_for_user(user_id: int) -> dict[date, int]:
|
def get_daily_calorie_dict_for_user(user_id: int) -> dict[date, int]:
|
||||||
"""Return {day: total_calories} for all days with scrobbles, in one query."""
|
"""Return {day: total_calories} for all days with scrobbles, in one query."""
|
||||||
|
|||||||
@ -127,8 +127,9 @@ class RecentScrobbleList(ListView):
|
|||||||
if user.is_authenticated:
|
if user.is_authenticated:
|
||||||
if scrobble_url := self.request.GET.get("scrobble_url", ""):
|
if scrobble_url := self.request.GET.get("scrobble_url", ""):
|
||||||
action = self.request.GET.get("action", "")
|
action = self.request.GET.get("action", "")
|
||||||
|
source = self.request.GET.get("source", "Bookmarklet")
|
||||||
scrobble = manual_scrobble_from_url(
|
scrobble = manual_scrobble_from_url(
|
||||||
scrobble_url, self.request.user.id, action
|
scrobble_url, self.request.user.id, source, action
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(scrobble.redirect_url(user.id))
|
return HttpResponseRedirect(scrobble.redirect_url(user.id))
|
||||||
return super().get(*args, **kwargs)
|
return super().get(*args, **kwargs)
|
||||||
@ -948,10 +949,10 @@ class ScrobbleDetailView(DetailView):
|
|||||||
|
|
||||||
log = self.object.log or {}
|
log = self.object.log or {}
|
||||||
initial_notes = log.get("notes", [])
|
initial_notes = log.get("notes", [])
|
||||||
if isinstance(initial_notes, list) and isinstance(initial_notes[0], dict):
|
if isinstance(initial_notes, list) and len(initial_notes) > 0 and isinstance(initial_notes[0], dict):
|
||||||
notes_str = note_list_to_str(notes)
|
notes_str = note_list_to_str(notes)
|
||||||
else:
|
else:
|
||||||
notes_str = "\n".join(initial_notes)
|
notes_str = "\n".join(initial_notes) if initial_notes else ""
|
||||||
|
|
||||||
notes_str_fixed = notes_str.encode("utf-8").decode(
|
notes_str_fixed = notes_str.encode("utf-8").decode(
|
||||||
"unicode_escape"
|
"unicode_escape"
|
||||||
|
|||||||
@ -244,7 +244,7 @@ class SportEvent(ScrobblableMixin):
|
|||||||
"player_two": player_two,
|
"player_two": player_two,
|
||||||
"start": data_dict.get("Start"),
|
"start": data_dict.get("Start"),
|
||||||
"round": round,
|
"round": round,
|
||||||
"run_time_seconds": data_dict.get("RunTime"),
|
"base_run_time_seconds": data_dict.get("RunTime"),
|
||||||
}
|
}
|
||||||
event, _created = cls.objects.get_or_create(**event_dict)
|
event, _created = cls.objects.get_or_create(**event_dict)
|
||||||
|
|
||||||
|
|||||||
8
vrobbler/apps/tasks/api/serializers.py
Normal file
8
vrobbler/apps/tasks/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from tasks import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class TaskSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Task
|
||||||
|
fields = "__all__"
|
||||||
10
vrobbler/apps/tasks/api/views.py
Normal file
10
vrobbler/apps/tasks/api/views.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from tasks.api import serializers
|
||||||
|
from tasks import models
|
||||||
|
|
||||||
|
|
||||||
|
class TaskViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Task.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.TaskSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
8
vrobbler/apps/trails/api/serializers.py
Normal file
8
vrobbler/apps/trails/api/serializers.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from trails import models
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class TrailSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Trail
|
||||||
|
fields = "__all__"
|
||||||
11
vrobbler/apps/trails/api/views.py
Normal file
11
vrobbler/apps/trails/api/views.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from trails.api import serializers
|
||||||
|
from trails import models
|
||||||
|
|
||||||
|
|
||||||
|
class TrailViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Trail.objects.all().order_by("-created")
|
||||||
|
serializer_class = serializers.TrailSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
@ -59,8 +59,11 @@ class VideoMetadata:
|
|||||||
|
|
||||||
def as_dict_with_cover_and_genres(self) -> tuple:
|
def as_dict_with_cover_and_genres(self) -> tuple:
|
||||||
video_dict = vars(self)
|
video_dict = vars(self)
|
||||||
|
series_id = ""
|
||||||
cover = None
|
cover = None
|
||||||
if "cover_url" in video_dict.keys():
|
if "cover_url" in video_dict.keys():
|
||||||
cover = video_dict.pop("cover_url", "")
|
cover = video_dict.pop("cover_url", "")
|
||||||
genres = video_dict.pop("genres", [])
|
genres = video_dict.pop("genres", [])
|
||||||
return video_dict, cover, genres
|
if "tv_series_imdb_id" in video_dict.keys():
|
||||||
|
series_id = video_dict.pop("tv_series_imdb_id")
|
||||||
|
return video_dict, series_id, cover, genres
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
import re
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@ -27,7 +28,9 @@ from vrobbler.apps.scrobbles.dataclasses import BaseLogData, WithPeopleLogData
|
|||||||
|
|
||||||
YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v="
|
YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v="
|
||||||
YOUTUBE_CHANNEL_URL = "https://www.youtube.com/channel/"
|
YOUTUBE_CHANNEL_URL = "https://www.youtube.com/channel/"
|
||||||
IMDB_VIDEO_URL = "https://www.imdb.com/title/tt"
|
YOUTUBE_ID_PATTERN = re.compile(r'^[A-Za-z0-9_-]{11}$')
|
||||||
|
|
||||||
|
IMDB_VIDEO_URL = "https://www.imdb.com/title/"
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
BNULL = {"blank": True, "null": True}
|
BNULL = {"blank": True, "null": True}
|
||||||
@ -136,6 +139,13 @@ class Series(TimeStampedModel):
|
|||||||
url = self.cover_image_medium.url
|
url = self.cover_image_medium.url
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def save_image_from_url(self, url: str, force_update: bool = False):
|
||||||
|
if not self.cover_image or (force_update and url):
|
||||||
|
r = requests.get(url)
|
||||||
|
if r.status_code == 200:
|
||||||
|
fname = f"{self.name}_{self.uuid}.jpg"
|
||||||
|
self.cover_image.save(fname, ContentFile(r.content), save=True)
|
||||||
|
|
||||||
def scrobbles_for_user(self, user_id: int, include_playing=False):
|
def scrobbles_for_user(self, user_id: int, include_playing=False):
|
||||||
from scrobbles.models import Scrobble
|
from scrobbles.models import Scrobble
|
||||||
|
|
||||||
@ -184,6 +194,32 @@ class Series(TimeStampedModel):
|
|||||||
if genres := imdb_dict.get("genres"):
|
if genres := imdb_dict.get("genres"):
|
||||||
self.genre.add(*genres)
|
self.genre.add(*genres)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def find_or_create(cls, imdb_id: str, overwrite: bool = True):
|
||||||
|
series, created = cls.objects.get_or_create(imdb_id=imdb_id)
|
||||||
|
|
||||||
|
if not created and not overwrite:
|
||||||
|
logger.info("Series not created and overwrite=False, returning")
|
||||||
|
return series
|
||||||
|
|
||||||
|
vdict, _, cover, genres = lookup_video_from_imdb(
|
||||||
|
imdb_id
|
||||||
|
).as_dict_with_cover_and_genres()
|
||||||
|
vdict.pop("video_type")
|
||||||
|
|
||||||
|
vdict["name"] = vdict.pop("title")
|
||||||
|
for k, v in vdict.items():
|
||||||
|
setattr(series, k, v)
|
||||||
|
series.save()
|
||||||
|
|
||||||
|
if cover:
|
||||||
|
series.save_image_from_url(cover)
|
||||||
|
if genres:
|
||||||
|
series.genre.add(*genres)
|
||||||
|
|
||||||
|
return series
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Video(ScrobblableMixin):
|
class Video(ScrobblableMixin):
|
||||||
COMPLETION_PERCENT = getattr(settings, "VIDEO_COMPLETION_PERCENT", 90)
|
COMPLETION_PERCENT = getattr(settings, "VIDEO_COMPLETION_PERCENT", 90)
|
||||||
@ -304,7 +340,7 @@ class Video(ScrobblableMixin):
|
|||||||
if not created and not overwrite:
|
if not created and not overwrite:
|
||||||
return video
|
return video
|
||||||
|
|
||||||
vdict, cover, genres = lookup_video_from_youtube(
|
vdict, _, cover, genres = lookup_video_from_youtube(
|
||||||
youtube_id
|
youtube_id
|
||||||
).as_dict_with_cover_and_genres()
|
).as_dict_with_cover_and_genres()
|
||||||
if created or overwrite:
|
if created or overwrite:
|
||||||
@ -320,28 +356,38 @@ class Video(ScrobblableMixin):
|
|||||||
def get_from_imdb_id(
|
def get_from_imdb_id(
|
||||||
cls, imdb_id: str, overwrite: bool = False
|
cls, imdb_id: str, overwrite: bool = False
|
||||||
) -> "Video":
|
) -> "Video":
|
||||||
if "tt" in imdb_id:
|
|
||||||
imdb_id = imdb_id[2:]
|
|
||||||
video, created = cls.objects.get_or_create(imdb_id=imdb_id)
|
video, created = cls.objects.get_or_create(imdb_id=imdb_id)
|
||||||
if not created and not overwrite:
|
if not created and not overwrite:
|
||||||
return video
|
return video
|
||||||
|
|
||||||
vdict, cover, genres = lookup_video_from_tmdb(
|
vdict, series_id, cover, genres = lookup_video_from_imdb(
|
||||||
imdb_id
|
imdb_id
|
||||||
).as_dict_with_cover_and_genres()
|
).as_dict_with_cover_and_genres()
|
||||||
|
|
||||||
if created or overwrite:
|
if created or overwrite:
|
||||||
for k, v in vdict.items():
|
for k, v in vdict.items():
|
||||||
setattr(video, k, v)
|
setattr(video, k, v)
|
||||||
|
|
||||||
|
if series_id:
|
||||||
|
video.tv_series = Series.find_or_create(imdb_id=series_id)
|
||||||
|
|
||||||
video.save()
|
video.save()
|
||||||
|
|
||||||
video.save_image_from_url(cover)
|
if cover:
|
||||||
video.genre.add(*genres)
|
video.save_image_from_url(cover)
|
||||||
|
if genres:
|
||||||
|
video.genre.add(*genres)
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_or_create(
|
def find_or_create(cls, source_id: str, overwrite: bool = True) -> "Video":
|
||||||
cls, data_dict: dict, post_keys: dict = JELLYFIN_POST_KEYS
|
if "tt" in source_id:
|
||||||
) -> Optional["Video"]:
|
return cls.get_from_imdb_id(source_id, overwrite)
|
||||||
"""Thes smallest of wrappers around our actual get or create utility."""
|
if bool(YOUTUBE_ID_PATTERN.match(source_id)):
|
||||||
imdb_key = post_keys.get("IMDB_ID", "").replace("tt", "")
|
return cls.get_from_youtube_id(source_id, overwrite)
|
||||||
return cls.get_from_imdb_id(data_dict.get(imdb_key))
|
|
||||||
|
#TODO scrobble but without a video obj?
|
||||||
|
logger.warning("Video ID not recognized, not scrobbling")
|
||||||
|
|
||||||
|
return
|
||||||
|
|||||||
@ -1,60 +1,21 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from imdb import Cinemagoer, helpers
|
from cinemagoerng import web as imdb
|
||||||
from videos.metadata import VideoMetadata, VideoType
|
from videos.metadata import VideoMetadata, VideoType
|
||||||
|
|
||||||
imdb_client = Cinemagoer()
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def lookup_video_from_imdb(
|
def lookup_video_from_imdb(imdb_id: str) -> VideoMetadata:
|
||||||
name_or_id: str, kind: str = "movie"
|
if not imdb_id.startswith("tt"):
|
||||||
) -> VideoMetadata:
|
logger.warning("This method requires an IMDB ID starting with 'tt'")
|
||||||
from videos.models import Series
|
return VideoMetadata()
|
||||||
|
|
||||||
# Very few video titles start with tt, but IMDB IDs often come in with it
|
|
||||||
if name_or_id.startswith("tt"):
|
|
||||||
name_or_id = name_or_id[2:]
|
|
||||||
|
|
||||||
imdb_id = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
imdb_id = int(name_or_id)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
video_metadata = VideoMetadata(imdb_id=imdb_id)
|
video_metadata = VideoMetadata(imdb_id=imdb_id)
|
||||||
imdb_result: dict = {}
|
imdb_result: dict = {}
|
||||||
|
|
||||||
imdb_result = imdb_client.get_movie(name_or_id)
|
imdb_result = imdb.get_title(imdb_id)
|
||||||
|
logger.debug(f"Found result from IMDB: {imdb_result.title}")
|
||||||
if not imdb_result:
|
|
||||||
imdb_result = {}
|
|
||||||
imdb_results: list = imdb_client.search_movie(name_or_id)
|
|
||||||
if len(imdb_results) > 1:
|
|
||||||
for result in imdb_results:
|
|
||||||
if result["kind"] == kind:
|
|
||||||
imdb_client.update(
|
|
||||||
result,
|
|
||||||
info=[
|
|
||||||
"plot",
|
|
||||||
"synopsis",
|
|
||||||
"taglines",
|
|
||||||
"next_episode",
|
|
||||||
"genres",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
imdb_result = result
|
|
||||||
break
|
|
||||||
|
|
||||||
if len(imdb_results) == 1:
|
|
||||||
imdb_result = imdb_results[0]
|
|
||||||
|
|
||||||
imdb_client.update(
|
|
||||||
imdb_result,
|
|
||||||
info=["plot", "synopsis", "taglines", "next_episode", "genres"],
|
|
||||||
)
|
|
||||||
|
|
||||||
if not imdb_result:
|
if not imdb_result:
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -63,39 +24,27 @@ def lookup_video_from_imdb(
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
video_metadata.cover_url = imdb_result.get("cover url")
|
video_metadata.imdb_id = imdb_id
|
||||||
if video_metadata.cover_url:
|
video_metadata.title = imdb_result.title
|
||||||
video_metadata.cover_url = helpers.resizeImage(
|
video_metadata.base_run_time_seconds = (
|
||||||
video_metadata.cover_url, width=800
|
imdb_result.runtime * 60
|
||||||
)
|
)
|
||||||
|
video_metadata.year = imdb_result.year
|
||||||
|
video_metadata.plot = imdb_result.plot.get("en-US", "")
|
||||||
|
video_metadata.imdb_rating = imdb_result.rating
|
||||||
|
video_metadata.genres = imdb_result.genres
|
||||||
|
video_metadata.cover_url = imdb_result.primary_image
|
||||||
|
|
||||||
video_metadata.video_type = VideoType.MOVIE.value
|
video_metadata.video_type = VideoType.MOVIE.value
|
||||||
series_name = None
|
if imdb_result.type_id == "tvEpisode":
|
||||||
if imdb_result.get("kind") == "episode":
|
video_metadata.video_type = VideoType.TV_EPISODE.value
|
||||||
try:
|
|
||||||
series_name = imdb_result.get("episode of", None).data.get(
|
|
||||||
"title", None
|
|
||||||
)
|
|
||||||
except IndexError:
|
|
||||||
series_name = None
|
|
||||||
if series_name:
|
|
||||||
series, _ = Series.objects.get_or_create(name=series_name)
|
|
||||||
video_metadata.video_type = VideoType.TV_EPISODE.value
|
|
||||||
video_metadata.tv_series_id = series.id
|
|
||||||
|
|
||||||
if imdb_result.get("runtimes"):
|
series = imdb_result.series
|
||||||
video_metadata.base_run_time_seconds = (
|
video_metadata.tv_series_imdb_id = series.imdb_id
|
||||||
int(imdb_result.get("runtimes")[0]) * 60
|
video_metadata.tv_series_title = series.title
|
||||||
)
|
video_metadata.episode_number = imdb_result.episode
|
||||||
|
video_metadata.season_number = imdb_result.season
|
||||||
|
video_metadata.next_imdb_id = imdb_result.next_episode_id
|
||||||
|
|
||||||
video_metadata.imdb_id = name_or_id
|
|
||||||
video_metadata.title = imdb_result.get("title", "")
|
|
||||||
video_metadata.episode_number = imdb_result.get("episode", None)
|
|
||||||
video_metadata.season_number = imdb_result.get("season", None)
|
|
||||||
video_metadata.next_imdb_id = imdb_result.get("next episode", None)
|
|
||||||
video_metadata.year = imdb_result.get("year", None)
|
|
||||||
video_metadata.plot = imdb_result.get("plot outline", "")
|
|
||||||
video_metadata.imdb_rating = imdb_result.get("rating", None)
|
|
||||||
video_metadata.genres = imdb_result.get("genres", [])
|
|
||||||
|
|
||||||
return video_metadata
|
return video_metadata
|
||||||
|
|||||||
@ -1,51 +1,24 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from scrobbles.utils import convert_to_seconds
|
from videos.models import Video
|
||||||
from videos.imdb import lookup_video_from_imdb
|
from django.db import IntegrityError
|
||||||
from videos.models import Series, Video
|
#from videos.skatevideosite import lookup_video_from_skatevideosite
|
||||||
from videos.skatevideosite import lookup_video_from_skatevideosite
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_or_create_video(data_dict: dict, post_keys: dict, force_update=False):
|
def clean_up_videos():
|
||||||
name_or_id = data_dict.get(post_keys.get("IMDB_ID"), "") or data_dict.get(
|
videos = Video.objects.filter(imdb_id__isnull=False).exclude(imdb_id__icontains="tt")
|
||||||
post_keys.get("VIDEO_TITLE"), ""
|
|
||||||
)
|
|
||||||
|
|
||||||
video = Video.objects.filter(imdb_id=name_or_id).first()
|
for video in videos:
|
||||||
if video:
|
logger.info(f"Fixing imdb_id for {video}")
|
||||||
return video
|
video.imdb_id = "tt" + video.imdb_id
|
||||||
|
try:
|
||||||
|
video.save(update_fields=["imdb_id"])
|
||||||
|
except IntegrityError:
|
||||||
|
new_video = Video.objects.filter(imdb_id="tt" + video.imdb_id).first()
|
||||||
|
video.scrobble_set.all().update(video=new_video)
|
||||||
|
video.delete()
|
||||||
|
|
||||||
imdb_metadata = lookup_video_from_imdb(name_or_id)
|
videos = Video.objects.filter(scrobble__isnull=True)
|
||||||
# skatevideosite_metadata = lookup_video_from_skatevideosite(name_or_id)
|
videos.delete()
|
||||||
# youtube_metadata = {} # TODO lookup_video_from_youtube(name_or_id)
|
|
||||||
|
|
||||||
video_dict = imdb_metadata
|
|
||||||
if not video_dict:
|
|
||||||
logger.info(
|
|
||||||
"No video found on imdb, skatevideosite or youtube, cannot scrobble",
|
|
||||||
extra={"name_or_id": name_or_id},
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
video = Video.get_from_imdb_id(video_dict.get("imdb_id")
|
|
||||||
|
|
||||||
if not "overview" in video_dict.keys():
|
|
||||||
video_dict["overview"] = data_dict.get(
|
|
||||||
post_keys.get("OVERVIEW"), None
|
|
||||||
)
|
|
||||||
if not "tagline" in video_dict.keys():
|
|
||||||
video_dict["tagline"] = data_dict.get(
|
|
||||||
post_keys.get("TAGLINE"), None
|
|
||||||
)
|
|
||||||
if not "tmdb_id" in video_dict.keys():
|
|
||||||
video_dict["tmdb_id"] = data_dict.get(
|
|
||||||
post_keys.get("TMDB_ID"), None
|
|
||||||
)
|
|
||||||
|
|
||||||
return video
|
|
||||||
|
|
||||||
|
|
||||||
def get_or_create_video_from_skatevideosite(title: str, force_update: bool=True):
|
|
||||||
return
|
|
||||||
|
|||||||
14
vrobbler/apps/webpages/api/serializers.py
Normal file
14
vrobbler/apps/webpages/api/serializers.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from webpages.models import Domain, WebPage
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class DomainSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Domain
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
|
class WebPageSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = WebPage
|
||||||
|
fields = "__all__"
|
||||||
19
vrobbler/apps/webpages/api/views.py
Normal file
19
vrobbler/apps/webpages/api/views.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
|
from webpages.api.serializers import (
|
||||||
|
DomainSerializer,
|
||||||
|
WebPageSerializer,
|
||||||
|
)
|
||||||
|
from webpages.models import Domain, WebPage
|
||||||
|
|
||||||
|
|
||||||
|
class DomainViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Domain.objects.all().order_by("-created")
|
||||||
|
serializer_class = DomainSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class WebPageViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = WebPage.objects.all().order_by("-created")
|
||||||
|
serializer_class = WebPageSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
43
vrobbler/templates/_longplay_scrobblable_list.html
Normal file
43
vrobbler/templates/_longplay_scrobblable_list.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{% load urlreplace %}
|
||||||
|
{% load naturalduration %}
|
||||||
|
|
||||||
|
<table class="table table-striped table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Latest</th>
|
||||||
|
<th scope="col">Title</th>
|
||||||
|
<th scope="col">Scrobbles</th>
|
||||||
|
<th scope="col">Complete</th>
|
||||||
|
<th scope="col">Start</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for obj in object_list %}
|
||||||
|
{% if obj.title %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{obj.scrobble_set.last.get_absolute_url}}">{{obj.scrobble_set.last.local_timestamp}}
|
||||||
|
<td><a href="{{obj.get_absolute_url}}">{{obj}}</a></td>
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<td>{{obj.scrobble_count}}</td>
|
||||||
|
<td>{% if obj.scrobble_set.last.logdata.long_play_complete == True %}Yes{% endif %}</td>
|
||||||
|
<td><a type="button" class="btn btn-sm btn-primary" href="{{obj.start_url}}">Scrobble</a></td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p class="pagination">
|
||||||
|
<span class="page-links">
|
||||||
|
{% if page_obj.has_previous %}
|
||||||
|
<a href="?{% urlreplace page=page_obj.previous_page_number %}">prev</a>
|
||||||
|
{% endif %}
|
||||||
|
<span class="page-current">
|
||||||
|
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
|
||||||
|
</span>
|
||||||
|
{% if page_obj.has_next %}
|
||||||
|
<a href="?{% urlreplace page=page_obj.next_page_number %}">next</a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
{% include "_scrobblable_list.html" %}
|
{% include "_longplay_scrobblable_list.html" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
{% include "_scrobblable_list.html" %}
|
{% include "_longplay_scrobblable_list.html" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
{% include "_scrobblable_list.html" %}
|
{% include "_longplay_scrobblable_list.html" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -66,9 +66,16 @@ dd {
|
|||||||
{% if object.overview %}<p><em>{{object.overview}}</em></p>{% endif %}
|
{% if object.overview %}<p><em>{{object.overview}}</em></p>{% endif %}
|
||||||
{% if object.plot%}<p>{{object.plot|safe|linebreaks|truncatewords:160}}</p>{% endif %}
|
{% if object.plot%}<p>{{object.plot|safe|linebreaks|truncatewords:160}}</p>{% endif %}
|
||||||
<hr />
|
<hr />
|
||||||
|
{% if object.imdb_id %}
|
||||||
<p style="float:right;">
|
<p style="float:right;">
|
||||||
<a href="{{object.imdb_link}}"><img src="{% static "images/imdb_logo.png" %}" width=35></a>
|
<a href="{{object.imdb_link}}"><img src="{% static "images/imdb_logo.png" %}" width=35></a>
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if object.youtube_id %}
|
||||||
|
<p style="float:right;">
|
||||||
|
<a href="{{object.youtube_link}}"><img src="{% static "images/youtube_logo.png" %}" width=35></a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="deets">
|
<div class="deets">
|
||||||
|
|||||||
@ -4,21 +4,35 @@ from oauth2_provider import urls as oauth2_urls
|
|||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
|
|
||||||
import vrobbler.apps.scrobbles.views as scrobbles_views
|
import vrobbler.apps.scrobbles.views as scrobbles_views
|
||||||
|
|
||||||
from vrobbler.apps.boardgames import urls as boardgame_urls
|
from vrobbler.apps.boardgames import urls as boardgame_urls
|
||||||
|
from vrobbler.apps.boardgames.api.views import BoardGameViewSet, BoardGameDesignerViewSet, BoardGamePublisherViewSet, BoardGameLocationViewSet
|
||||||
|
|
||||||
from vrobbler.apps.books import urls as book_urls
|
from vrobbler.apps.books import urls as book_urls
|
||||||
from vrobbler.apps.books.api.views import AuthorViewSet, BookViewSet
|
from vrobbler.apps.books.api.views import AuthorViewSet, BookViewSet
|
||||||
from vrobbler.apps.bricksets import urls as bricksets_urls
|
|
||||||
from vrobbler.apps.lifeevents import urls as lifeevents_urls
|
from vrobbler.apps.lifeevents import urls as lifeevents_urls
|
||||||
|
from vrobbler.apps.lifeevents.api.views import LifeEventViewSet
|
||||||
|
|
||||||
from vrobbler.apps.locations import urls as locations_urls
|
from vrobbler.apps.locations import urls as locations_urls
|
||||||
|
from vrobbler.apps.locations.api.views import GeoLocationViewSet
|
||||||
|
|
||||||
from vrobbler.apps.moods import urls as moods_urls
|
from vrobbler.apps.moods import urls as moods_urls
|
||||||
|
from vrobbler.apps.moods.api.views import MoodViewSet
|
||||||
|
|
||||||
|
from vrobbler.apps.foods import urls as foods_urls
|
||||||
|
from vrobbler.apps.foods.api.views import FoodViewSet, FoodCategoryViewSet
|
||||||
|
|
||||||
from vrobbler.apps.music import urls as music_urls
|
from vrobbler.apps.music import urls as music_urls
|
||||||
from vrobbler.apps.music.api.views import (
|
from vrobbler.apps.music.api.views import (
|
||||||
AlbumViewSet,
|
AlbumViewSet,
|
||||||
ArtistViewSet,
|
ArtistViewSet,
|
||||||
TrackViewSet,
|
TrackViewSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
from vrobbler.apps.podcasts import urls as podcast_urls
|
from vrobbler.apps.podcasts import urls as podcast_urls
|
||||||
from vrobbler.apps.profiles.api.views import UserProfileViewSet, UserViewSet
|
from vrobbler.apps.podcasts.api.views import ProducerViewSet, PodcastViewSet, PodcastEpisodeViewSet
|
||||||
|
|
||||||
from vrobbler.apps.scrobbles import urls as scrobble_urls
|
from vrobbler.apps.scrobbles import urls as scrobble_urls
|
||||||
from vrobbler.apps.scrobbles.api.views import (
|
from vrobbler.apps.scrobbles.api.views import (
|
||||||
AudioScrobblerTSVImportViewSet,
|
AudioScrobblerTSVImportViewSet,
|
||||||
@ -26,6 +40,7 @@ from vrobbler.apps.scrobbles.api.views import (
|
|||||||
LastFmImportViewSet,
|
LastFmImportViewSet,
|
||||||
ScrobbleViewSet,
|
ScrobbleViewSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
from vrobbler.apps.sports import urls as sports_urls
|
from vrobbler.apps.sports import urls as sports_urls
|
||||||
from vrobbler.apps.sports.api.views import (
|
from vrobbler.apps.sports.api.views import (
|
||||||
LeagueViewSet,
|
LeagueViewSet,
|
||||||
@ -36,15 +51,29 @@ from vrobbler.apps.sports.api.views import (
|
|||||||
TeamViewSet,
|
TeamViewSet,
|
||||||
)
|
)
|
||||||
from vrobbler.apps.tasks import urls as tasks_urls
|
from vrobbler.apps.tasks import urls as tasks_urls
|
||||||
|
from vrobbler.apps.tasks.api.views import TaskViewSet
|
||||||
|
|
||||||
from vrobbler.apps.profiles import urls as profiles_urls
|
from vrobbler.apps.profiles import urls as profiles_urls
|
||||||
|
from vrobbler.apps.profiles.api.views import UserProfileViewSet, UserViewSet
|
||||||
|
|
||||||
from vrobbler.apps.trails import urls as trails_urls
|
from vrobbler.apps.trails import urls as trails_urls
|
||||||
|
from vrobbler.apps.trails.api.views import TrailViewSet
|
||||||
|
|
||||||
from vrobbler.apps.beers import urls as beers_urls
|
from vrobbler.apps.beers import urls as beers_urls
|
||||||
from vrobbler.apps.foods import urls as foods_urls
|
from vrobbler.apps.beers.api.views import BeerViewSet, BeerProducerViewSet, BeerStyleViewSet
|
||||||
|
|
||||||
from vrobbler.apps.puzzles import urls as puzzles_urls
|
from vrobbler.apps.puzzles import urls as puzzles_urls
|
||||||
|
from vrobbler.apps.puzzles.api.views import PuzzleViewSet, PuzzleManufacturerViewSet
|
||||||
from vrobbler.apps.videogames import urls as videogame_urls
|
from vrobbler.apps.videogames import urls as videogame_urls
|
||||||
|
|
||||||
from vrobbler.apps.videos import urls as video_urls
|
from vrobbler.apps.videos import urls as video_urls
|
||||||
from vrobbler.apps.videos.api.views import SeriesViewSet, VideoViewSet
|
from vrobbler.apps.videos.api.views import SeriesViewSet, VideoViewSet
|
||||||
|
|
||||||
|
from vrobbler.apps.bricksets import urls as bricksets_urls
|
||||||
|
from vrobbler.apps.bricksets.api.views import BrickSetViewSet
|
||||||
|
|
||||||
from vrobbler.apps.webpages import urls as webpages_urls
|
from vrobbler.apps.webpages import urls as webpages_urls
|
||||||
|
from vrobbler.apps.webpages.api.views import DomainViewSet, WebPageViewSet
|
||||||
|
|
||||||
# from vrobbler.apps.modern_ui import urls as modern_ui_urls
|
# from vrobbler.apps.modern_ui import urls as modern_ui_urls
|
||||||
|
|
||||||
@ -68,6 +97,26 @@ router.register(r"sport-events", SportEventViewSet)
|
|||||||
router.register(r"teams", TeamViewSet)
|
router.register(r"teams", TeamViewSet)
|
||||||
router.register(r"users", UserViewSet)
|
router.register(r"users", UserViewSet)
|
||||||
router.register(r"profiles", UserProfileViewSet)
|
router.register(r"profiles", UserProfileViewSet)
|
||||||
|
router.register(r"domains", DomainViewSet)
|
||||||
|
router.register(r"webpages", WebPageViewSet)
|
||||||
|
router.register(r"foods", FoodViewSet)
|
||||||
|
router.register(r"moods", MoodViewSet)
|
||||||
|
router.register(r"tasks", TaskViewSet)
|
||||||
|
router.register(r"locations", GeoLocationViewSet)
|
||||||
|
router.register(r"beers", BeerViewSet)
|
||||||
|
router.register(r"beer-producers", BeerProducerViewSet)
|
||||||
|
router.register(r"beer-styles", BeerStyleViewSet)
|
||||||
|
router.register(r"boardgames", BoardGameViewSet)
|
||||||
|
router.register(r"boardgame-designers", BoardGameDesignerViewSet)
|
||||||
|
router.register(r"boardgame-publishers", BoardGamePublisherViewSet)
|
||||||
|
router.register(r"boardgame-locations", BoardGameLocationViewSet)
|
||||||
|
router.register(r"podcast-producers", ProducerViewSet)
|
||||||
|
router.register(r"podcast-episodes", PodcastEpisodeViewSet)
|
||||||
|
router.register(r"podcasts", PodcastViewSet)
|
||||||
|
router.register(r"puzzle-manufacturers", PuzzleManufacturerViewSet)
|
||||||
|
router.register(r"puzzles", PuzzleViewSet)
|
||||||
|
router.register(r"bricksets", BrickSetViewSet)
|
||||||
|
router.register(r"lifeevents", LifeEventViewSet)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("api/v1/", include(router.urls)),
|
path("api/v1/", include(router.urls)),
|
||||||
|
|||||||
Reference in New Issue
Block a user