Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
5b75ef3a27 | |||
e7434f976e | |||
fbc843ad6d | |||
![]() |
166712515d | ||
![]() |
bafa23131a | ||
![]() |
782ab1783d | ||
72fd5457e6 | |||
6c6c09a158 | |||
82f8a61d16 | |||
f8e1012f3e | |||
a3c5b350fc | |||
0dc358d053 | |||
0279f667b3 | |||
![]() |
7abf7a939f | ||
![]() |
172b29e56a | ||
bdcaf3747b | |||
8f802ed046 |
@ -111,6 +111,7 @@ controlflow {
|
||||
<ref refid="4c28103c-ee11-11ef-aaf7-89e86c884103"/>
|
||||
<ref refid="650af1b7-ee11-11ef-a839-89e86c884103"/>
|
||||
<ref refid="79033e7b-ee11-11ef-bd6c-89e86c884103"/>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</reflist>
|
||||
</ownedType>
|
||||
<owningPackage>
|
||||
@ -126,6 +127,7 @@ controlflow {
|
||||
<ref refid="4c28103c-ee11-11ef-aaf7-89e86c884103"/>
|
||||
<ref refid="650af1b7-ee11-11ef-a839-89e86c884103"/>
|
||||
<ref refid="79033e7b-ee11-11ef-bd6c-89e86c884103"/>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</reflist>
|
||||
</packagedElement>
|
||||
</UML:Package>
|
||||
@ -373,6 +375,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<ref refid="650b3c91-ee11-11ef-b15a-89e86c884103"/>
|
||||
<ref refid="7903854f-ee11-11ef-bbf6-89e86c884103"/>
|
||||
<ref refid="bae1bc56-ee12-11ef-8a75-89e86c884103"/>
|
||||
<ref refid="a7b170fd-ee1b-11ef-933e-89e86c884103"/>
|
||||
<ref refid="4b4d835f-ee11-11ef-a57a-89e86c884103"/>
|
||||
<ref refid="8b31e95c-ee11-11ef-9bbf-89e86c884103"/>
|
||||
<ref refid="9071eb00-ee11-11ef-a0be-89e86c884103"/>
|
||||
@ -391,7 +394,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Comment>
|
||||
<UML:CommentItem id="6e4703fe-71b6-11ec-a409-f47b099bf663">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 133.29296875, 17.285152435302734)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 126.22541649148083, -111.56346769146282)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 0.0)</val>
|
||||
@ -481,16 +484,16 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Class>
|
||||
<UML:ClassItem id="5c2f3216-ee0f-11ef-918b-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 345.78324127197266, 680.6172180175781)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 59.49042039678521, 676.7889605442139)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 0.0)</val>
|
||||
<val>(-4.473890692342593, 0.0)</val>
|
||||
</top-left>
|
||||
<width>
|
||||
<val>632.0</val>
|
||||
<val>581.5334231350598</val>
|
||||
</width>
|
||||
<height>
|
||||
<val>205.20700073242188</val>
|
||||
<val>103.7992092219963</val>
|
||||
</height>
|
||||
<diagram>
|
||||
<ref refid="585f224c-71b6-11ec-a409-f47b099bf663"/>
|
||||
@ -541,12 +544,17 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<name>
|
||||
<val>History</val>
|
||||
</name>
|
||||
<note>
|
||||
<val></val>
|
||||
</note>
|
||||
<ownedOperation>
|
||||
<reflist>
|
||||
<ref refid="8c325cde-ee10-11ef-b9a0-89e86c884103"/>
|
||||
<ref refid="169850f1-ee11-11ef-bcb1-89e86c884103"/>
|
||||
<ref refid="94fc9d0a-ee12-11ef-9424-89e86c884103"/>
|
||||
<ref refid="0e62ffe8-ee13-11ef-b1cb-89e86c884103"/>
|
||||
<ref refid="ac32a9bd-ee13-11ef-a965-89e86c884103"/>
|
||||
<ref refid="3150c041-ee14-11ef-9394-89e86c884103"/>
|
||||
<ref refid="9409fcad-ee1b-11ef-9c9f-89e86c884103"/>
|
||||
</reflist>
|
||||
</ownedOperation>
|
||||
<owningPackage>
|
||||
@ -563,7 +571,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Class>
|
||||
<UML:ClassItem id="69505392-ee10-11ef-b744-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 186.63282775878906, 443.60939025878906)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 186.63282775878895, 443.60939025878906)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 0.0)</val>
|
||||
@ -614,17 +622,6 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<val>string</val>
|
||||
</typeValue>
|
||||
</UML:Parameter>
|
||||
<UML:Operation id="169850f1-ee11-11ef-bcb1-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="69500f2c-ee10-11ef-a0f8-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>1</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>__size__</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:AssociationItem id="4b4d835f-ee11-11ef-a57a-89e86c884103">
|
||||
<diagram>
|
||||
<ref refid="585f224c-71b6-11ec-a409-f47b099bf663"/>
|
||||
@ -645,10 +642,10 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<ref refid="4c2876c8-ee11-11ef-a414-89e86c884103"/>
|
||||
</tail_subject>
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 427.53533935546875, 679.4648742675781)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 427.1573380812623, 679.4648742675781)</val>
|
||||
</matrix>
|
||||
<points>
|
||||
<val>[(0.0, 1.15234375), (0.0, -71.09770202636719)]</val>
|
||||
<val>[(0.37800127420644003, -2.6759137233642605), (0.37800127420644003, -71.09770202636719)]</val>
|
||||
</points>
|
||||
<head-connection>
|
||||
<ref refid="5c2f3216-ee0f-11ef-918b-89e86c884103"/>
|
||||
@ -720,7 +717,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Property>
|
||||
<UML:Class id="650af1b7-ee11-11ef-a839-89e86c884103">
|
||||
<name>
|
||||
<val>HistoryYouTube</val>
|
||||
<val>YouTubeHistory</val>
|
||||
</name>
|
||||
<owningPackage>
|
||||
<ref refid="f3a82730-71b1-11ec-a409-f47b099bf663"/>
|
||||
@ -736,7 +733,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Class>
|
||||
<UML:ClassItem id="650b3c91-ee11-11ef-b15a-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 91.67303721110027, 224.98699188232425)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 86.18801116943362, 224.98699188232428)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 44.798164367675795)</val>
|
||||
@ -762,7 +759,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:ClassItem>
|
||||
<UML:Class id="79033e7b-ee11-11ef-bd6c-89e86c884103">
|
||||
<name>
|
||||
<val>HistoryFreeTube</val>
|
||||
<val>FreeTubeHistory</val>
|
||||
</name>
|
||||
<owningPackage>
|
||||
<ref refid="f3a82730-71b1-11ec-a409-f47b099bf663"/>
|
||||
@ -778,7 +775,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Class>
|
||||
<UML:ClassItem id="7903854f-ee11-11ef-bbf6-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 380.05679575602204, 226.81316375732428)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 380.05679575602204, 226.81316375732425)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 43.58071645100908)</val>
|
||||
@ -816,7 +813,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 223.12159220377606, 442.6041793823242)</val>
|
||||
</matrix>
|
||||
<points>
|
||||
<val>[(0.0, 0.0), (6.154947234916875, -114.46289062499994)]</val>
|
||||
<val>[(0.0, 0.0), (0.6699211932502465, -114.46289062499994)]</val>
|
||||
</points>
|
||||
<tail-connection>
|
||||
<ref refid="650b3c91-ee11-11ef-b15a-89e86c884103"/>
|
||||
@ -855,7 +852,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Operation>
|
||||
<UML:Comment id="bae1b667-ee12-11ef-a5d2-89e86c884103">
|
||||
<body>
|
||||
<val>When parse_history() is called, it should identify and return the correct history type. It can leverage the is_this_type() function that the implementers of this interface should implement to identify whether it's the correct type.</val>
|
||||
<val>When parse_history() is called, it should identify and return the correct history type. It can leverage the is_this_type() function that the implementers of this interface should have to identify whether it's the correct type.</val>
|
||||
</body>
|
||||
<presentation>
|
||||
<reflist>
|
||||
@ -865,7 +862,7 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
</UML:Comment>
|
||||
<UML:CommentItem id="bae1bc56-ee12-11ef-8a75-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 532.4830907185875, 411.48828125)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 531.3502782185875, 411.48828125)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 0.0)</val>
|
||||
@ -891,23 +888,228 @@ existing classes or even new classes with specific responsibilities.</val>
|
||||
<val>1</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>is_this_type</val>
|
||||
<val>+ is_this_type(in filename: string) -> bool</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="ac32a9bd-ee13-11ef-a965-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="69500f2c-ee10-11ef-a0f8-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>1</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ get_video(in index: int) -> Video</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="3150c041-ee14-11ef-9394-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="69500f2c-ee10-11ef-a0f8-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>1</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>__iter__</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="9409fcad-ee1b-11ef-9c9f-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="69500f2c-ee10-11ef-a0f8-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>1</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>__size__</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Class id="a7b123a2-ee1b-11ef-8246-89e86c884103">
|
||||
<name>
|
||||
<val>Video</val>
|
||||
</name>
|
||||
<ownedOperation>
|
||||
<reflist>
|
||||
<ref refid="b9ef8e0b-ee1b-11ef-8d43-89e86c884103"/>
|
||||
<ref refid="d70ae633-ee1b-11ef-b247-89e86c884103"/>
|
||||
<ref refid="204b8a7a-ee1c-11ef-bcda-89e86c884103"/>
|
||||
<ref refid="32cd5fd7-ee1c-11ef-99cc-89e86c884103"/>
|
||||
<ref refid="adcc7121-ee1c-11ef-a942-89e86c884103"/>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</reflist>
|
||||
</ownedOperation>
|
||||
<owningPackage>
|
||||
<ref refid="f3a82730-71b1-11ec-a409-f47b099bf663"/>
|
||||
</owningPackage>
|
||||
<package>
|
||||
<ref refid="f3a82730-71b1-11ec-a409-f47b099bf663"/>
|
||||
</package>
|
||||
<presentation>
|
||||
<reflist>
|
||||
<ref refid="a7b170fd-ee1b-11ef-933e-89e86c884103"/>
|
||||
</reflist>
|
||||
</presentation>
|
||||
</UML:Class>
|
||||
<UML:ClassItem id="a7b170fd-ee1b-11ef-933e-89e86c884103">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 863.6850618434581, 361.7811660068871)</val>
|
||||
</matrix>
|
||||
<top-left>
|
||||
<val>(0.0, 0.0)</val>
|
||||
</top-left>
|
||||
<width>
|
||||
<val>644.0</val>
|
||||
</width>
|
||||
<height>
|
||||
<val>161.64602675087428</val>
|
||||
</height>
|
||||
<diagram>
|
||||
<ref refid="585f224c-71b6-11ec-a409-f47b099bf663"/>
|
||||
</diagram>
|
||||
<show_attributes>
|
||||
<val>0</val>
|
||||
</show_attributes>
|
||||
<subject>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</subject>
|
||||
</UML:ClassItem>
|
||||
<UML:Operation id="b9ef8e0b-ee1b-11ef-8d43-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>0</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ getID() -> string</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="d70ae633-ee1b-11ef-b247-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>0</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ getWatchTime() -> float</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="204b8a7a-ee1c-11ef-bcda-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>0</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ getWatchProgress() -> float</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="32cd5fd7-ee1c-11ef-99cc-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>0</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ getTitle() -> string</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="adcc7121-ee1c-11ef-a942-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<isAbstract>
|
||||
<val>0</val>
|
||||
</isAbstract>
|
||||
<name>
|
||||
<val>+ getDescription() -> string</val>
|
||||
</name>
|
||||
</UML:Operation>
|
||||
<UML:Operation id="ca8ee3af-ee1d-11ef-80d5-89e86c884103">
|
||||
<class_>
|
||||
<ref refid="a7b123a2-ee1b-11ef-8246-89e86c884103"/>
|
||||
</class_>
|
||||
<name>
|
||||
<val>Video</val>
|
||||
</name>
|
||||
<ownedParameter>
|
||||
<reflist>
|
||||
<ref refid="0e64ddce-ee13-11ef-961a-89e86c884103"/>
|
||||
<ref refid="ca99bc30-ee1d-11ef-9876-89e86c884103"/>
|
||||
<ref refid="caa3f065-ee1d-11ef-b31b-89e86c884103"/>
|
||||
<ref refid="caae0024-ee1d-11ef-9884-89e86c884103"/>
|
||||
<ref refid="cab8031a-ee1d-11ef-a309-89e86c884103"/>
|
||||
<ref refid="cac1ffed-ee1d-11ef-9df7-89e86c884103"/>
|
||||
</reflist>
|
||||
</ownedParameter>
|
||||
</UML:Operation>
|
||||
<UML:Parameter id="0e64ddce-ee13-11ef-961a-89e86c884103">
|
||||
<UML:Parameter id="ca99bc30-ee1d-11ef-9876-89e86c884103">
|
||||
<direction>
|
||||
<val>in</val>
|
||||
</direction>
|
||||
<name>
|
||||
<val>filename</val>
|
||||
<val>id</val>
|
||||
</name>
|
||||
<ownerFormalParam>
|
||||
<ref refid="0e62ffe8-ee13-11ef-b1cb-89e86c884103"/>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</ownerFormalParam>
|
||||
<typeValue>
|
||||
<val>string</val>
|
||||
</typeValue>
|
||||
</UML:Parameter>
|
||||
<UML:Parameter id="caa3f065-ee1d-11ef-b31b-89e86c884103">
|
||||
<direction>
|
||||
<val>in</val>
|
||||
</direction>
|
||||
<name>
|
||||
<val>watch_time</val>
|
||||
</name>
|
||||
<ownerFormalParam>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</ownerFormalParam>
|
||||
<typeValue>
|
||||
<val>float</val>
|
||||
</typeValue>
|
||||
</UML:Parameter>
|
||||
<UML:Parameter id="caae0024-ee1d-11ef-9884-89e86c884103">
|
||||
<direction>
|
||||
<val>in</val>
|
||||
</direction>
|
||||
<name>
|
||||
<val>watch_progress</val>
|
||||
</name>
|
||||
<ownerFormalParam>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</ownerFormalParam>
|
||||
<typeValue>
|
||||
<val>float</val>
|
||||
</typeValue>
|
||||
</UML:Parameter>
|
||||
<UML:Parameter id="cab8031a-ee1d-11ef-a309-89e86c884103">
|
||||
<direction>
|
||||
<val>in</val>
|
||||
</direction>
|
||||
<name>
|
||||
<val>title</val>
|
||||
</name>
|
||||
<ownerFormalParam>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</ownerFormalParam>
|
||||
<typeValue>
|
||||
<val>string</val>
|
||||
</typeValue>
|
||||
</UML:Parameter>
|
||||
<UML:Parameter id="cac1ffed-ee1d-11ef-9df7-89e86c884103">
|
||||
<direction>
|
||||
<val>in</val>
|
||||
</direction>
|
||||
<name>
|
||||
<val>description</val>
|
||||
</name>
|
||||
<ownerFormalParam>
|
||||
<ref refid="ca8ee3af-ee1d-11ef-80d5-89e86c884103"/>
|
||||
</ownerFormalParam>
|
||||
<typeValue>
|
||||
<val>string</val>
|
||||
|
@ -1,3 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import shadowtube.preprocess as prep
|
||||
import shadowtube.recommend as rec
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import requests
|
||||
from io import BytesIO
|
||||
from PIL import Image, ImageTk
|
||||
|
@ -1,2 +1,18 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from .preprocess import *
|
||||
from .recommend import *
|
||||
|
99
shadowtube/history.py
Normal file
99
shadowtube/history.py
Normal file
@ -0,0 +1,99 @@
|
||||
#
|
||||
# Copyright (c) 2025 Mykola Shulhin.
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
import json
|
||||
from typing import Iterator
|
||||
from .types import Video
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class History(ABC): # Abstract class
|
||||
@abstractmethod
|
||||
def __len__(self) -> int:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def parse_history(filename: str) -> "History":
|
||||
return FreeTubeHistory(filename)
|
||||
|
||||
@abstractmethod
|
||||
def is_this_type(self, filename: str) -> bool:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_video(self, index: int) -> Video:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def __iter__(self) -> Iterator[Video]:
|
||||
pass
|
||||
|
||||
|
||||
class FreeTubeHistory(History):
|
||||
def __init__(self, filename: str) -> None:
|
||||
parsed_data = []
|
||||
|
||||
with open(filename, "r", encoding="utf-8") as file:
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
try:
|
||||
parsed_data.append(json.loads(line))
|
||||
except json.JSONDecodeError:
|
||||
fixed_line = FreeTubeHistory._fix_unquoted_values(line)
|
||||
parsed_data.append(json.loads(fixed_line))
|
||||
|
||||
self._parsed_data = parsed_data
|
||||
|
||||
@staticmethod
|
||||
def _fix_unquoted_values(line: str) -> str:
|
||||
"""Attempts to fix unquoted values by adding quotes around them."""
|
||||
import re
|
||||
|
||||
def replacer(match):
|
||||
key, value = match.groups()
|
||||
if not (value.startswith('"') and value.endswith('"')):
|
||||
value = f'"{value}"' # Add quotes around the value
|
||||
return f'"{key}":{value}'
|
||||
|
||||
fixed_line = re.sub(r'"(\w+)":(\w+)', replacer, line)
|
||||
return fixed_line
|
||||
|
||||
@staticmethod
|
||||
def _to_video(entry) -> Video:
|
||||
return Video(
|
||||
id=entry["videoId"],
|
||||
title=entry["title"],
|
||||
description=entry["description"],
|
||||
watch_time=entry["timeWatched"],
|
||||
watch_progress=entry["watchProgress"],
|
||||
)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._parsed_data)
|
||||
|
||||
def is_this_type(self, filename: str) -> bool:
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_video(self, index: int) -> Video:
|
||||
return FreeTubeHistory._to_video(self._parsed_data[index])
|
||||
|
||||
def __iter__(self):
|
||||
for entry in self._parsed_data:
|
||||
yield FreeTubeHistory._to_video(entry)
|
@ -1,3 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import json
|
||||
import math
|
||||
from typing import List
|
||||
|
@ -1,3 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import sqlite3
|
||||
from random import sample
|
||||
|
||||
|
51
shadowtube/types.py
Normal file
51
shadowtube/types.py
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright (c) 2025 Fedir Kovalov.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
class Video:
|
||||
def __init__(
|
||||
self,
|
||||
id: str,
|
||||
title: str,
|
||||
description: str,
|
||||
watch_time: float,
|
||||
watch_progress: float,
|
||||
):
|
||||
self._id = id
|
||||
self._title = title
|
||||
self._description = description
|
||||
self._watch_time = watch_time
|
||||
self._watch_progress = watch_progress
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
return self._description
|
||||
|
||||
@property
|
||||
def watch_time(self):
|
||||
return self._watch_time
|
||||
|
||||
@property
|
||||
def watch_progress(self):
|
||||
return self._watch_progress
|
Loading…
Reference in New Issue
Block a user