Models

class tube.models.Videos(*args, **kwargs)[source]

Bases: Model

A class that represents the video model.

The class has the following attributes:

  • video_name (str): The name of the video.

  • owner (User): The owner of the video.

  • video_prev (ImageField): The preview of the video.

  • video_subs (FileField): The subtitles of the video.

  • yt_id (str): The YouTube ID of the video.

  • yt_url (str): The URL of the video.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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>
owner

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

save(*args, **kwargs)[source]

Save the video preview and subtitles. Resize the preview image and remove the tags from the subtitles file.

video_name

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

video_prev

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

video_subs

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
yt_id

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

yt_url

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