youtubes django module

Youtube posts module.

This module has one process: youtube_stream, it periodically fetches the API for the list of videos of each poster to follow, inserts new posts and missing stats for recent posts.

Management commands: creating data

youtube_stream

Management command to poll Youtube’s API and insert new posts and stats.

Youtube API returns the list of videos with likes for each poster. So, we have a thread per Poster to fetch the list every hour, add new posts and new stats for existing posts.

Run with:

buzzdetect youtube_stream

youtube_update_sources

AppConfig: Youtube specific config

class youtubes.apps.YoutubesConfig(app_name, app_module)[source]
account = 'youtubeaccount'
backend = 'google-oauth2'
loggers = (('youtubes', 'Youtube: all events'), ('youtubes.posts', 'Posts: all events'), ('youtubes.posters', 'Posters: all events'), ('youtubes.posters.pipeline', 'Posters: pipeline'), ('youtubes.posters.YoutubeAccount', 'Posters: sync'), ('youtubes.posters.update_sources', 'Posters: cron'))
name = 'youtubes'
pk = 2
poster_stat_per_kind = False
poster_stat_refresh(poster)[source]
static previous_minutes(minute)[source]
ready()[source]
score_unit = 'view'
score_unit_plural = 'views'
time_stats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
time_unit = 'hour'
verbose_name = 'Youtube'

Models

class youtubes.models.YoutubeAccount(id, name, hub, follow, app, account_ptr, channel_id, login, api_key)[source]
exception DoesNotExist
exception MultipleObjectsReturned
account_ptr

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

account_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

api_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

channel_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

login

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

login_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
sync(subscriptions=None)[source]
class youtubes.models.YoutubeRequest(account)[source]
exception RequestException(response)[source]
get(endpoint, **params)[source]
get_items(endpoint, **params)[source]
youtubes.models.account_sync(sender, instance, **kwargs)[source]
youtubes.models.get_entries(upstream_id)[source]

Views

class youtubes.views.YoutubePosterMissingList(**kwargs)[source]

Compare videos between the API call and database results.

Helps to find out if we’re missing any video or stat in the database.

Admin

class youtubes.admin.YoutubeAccountAdmin(model, admin_site)[source]
fields = ('name', 'hub', 'follow', 'channel_id', 'api_key', 'login')
media