Skip to content

Commit

Permalink
Updated database class and FFmpeg download path
Browse files Browse the repository at this point in the history
In this update, the database class is almost completed (create database from file is still pending) and FFmpeg was configured for converting videos directly to RAM using the /run/user/{uid} path
  • Loading branch information
Javinator9889 committed May 13, 2020
1 parent b8e3869 commit 7aebd0a
Show file tree
Hide file tree
Showing 14 changed files with 487 additions and 67 deletions.
7 changes: 6 additions & 1 deletion .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Design/Database/psql_model.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- PostgreSQL model for YouTubeMDBot application
-- Created by Javinator9889 - thu, 24 October, 2019
-- Last modification: mon, 4 November, 2019
-- Version 1.1
-- Last modification: Sat, 29 February, 2020
-- Version 1.2

-- DROP schema - only for testing
-- DROP SCHEMA IF EXISTS youtubemd CASCADE;
-- DROP TYPE IF EXISTS AFORMAT;
-- DROP TYPE IF EXISTS aquality;
-- DROP TYPE IF EXISTS behaviour;
DROP SCHEMA IF EXISTS youtubemd CASCADE;
DROP TYPE IF EXISTS AFORMAT;
DROP TYPE IF EXISTS aquality;
DROP TYPE IF EXISTS behaviour;

-- Custom "enum" types
CREATE TYPE AFORMAT AS ENUM ('mp3', 'm4a', 'ogg');
Expand Down Expand Up @@ -154,9 +154,9 @@ CREATE TABLE IF NOT EXISTS youtubemd.YouTubeStats
);

-- Additional indexes
CREATE INDEX youtubemd.user_preferences_ix ON youtubemd.Preferences ("user_id");
CREATE INDEX youtubemd.video_metadata_ix ON youtubemd.Video_Has_Metadata ("id", "metadata_id");
CREATE INDEX youtubemd.history_ix ON youtubemd.History ("id", "file_id", "user_id", "metadata_id");
CREATE INDEX user_preferences_idx ON youtubemd.Preferences ("user_id");
CREATE INDEX video_metadata_idx ON youtubemd.Video_Has_Metadata ("id", "metadata_id");
CREATE INDEX history_idx ON youtubemd.History ("id", "file_id", "user_id", "metadata_id");

-- Trigger that updates different stats
CREATE FUNCTION youtubemd.process_stats() RETURNS trigger AS
Expand Down Expand Up @@ -237,21 +237,21 @@ BEGIN
END;
$$ LANGUAGE plpgsql;

CREATE FUNCTION youtubemd.clear_daily_stats() AS
CREATE FUNCTION youtubemd.clear_daily_stats() RETURNS VOID AS
$$
BEGIN
UPDATE youtubemd.YouTubeStats SET daily_requests = 0;
END;
$$ LANGUAGE plpgsql;

CREATE FUNCTION youtubemd.clear_weekly_stats() AS
CREATE FUNCTION youtubemd.clear_weekly_stats() RETURNS VOID AS
$$
BEGIN
UPDATE youtubemd.YouTubeStats SET weekly_requests = 0;
END;
$$ LANGUAGE plpgsql;

CREATE FUNCTION youtubemd.clear_monthly_stats() AS
CREATE FUNCTION youtubemd.clear_monthly_stats() RETURNS VOID AS
$$
BEGIN
UPDATE youtubemd.YouTubeStats SET monthly_requests = 0;
Expand Down
6 changes: 3 additions & 3 deletions YouTubeMDBot/.idea/YouTubeMDBot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion YouTubeMDBot/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions YouTubeMDBot/.idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions YouTubeMDBot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# 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 .logging_utils import LoggingHandler
from .logging_utils import setup_logging

Expand Down
12 changes: 6 additions & 6 deletions YouTubeMDBot/audio/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from abc import ABC
from abc import abstractmethod
from typing import List
from subprocess import PIPE
from subprocess import Popen
from typing import List

from ..constants import FFMPEG_OPENER
from ..constants import FFMPEG_CONVERTER
from ..constants import FFMPEG_OPENER
from ..constants import FFMPEG_VOLUME


Expand Down Expand Up @@ -145,7 +145,7 @@ def convert(self) -> int:
:raises NotImplementedError when trying to access this method directly on super
class.
"""
raise NotImplementedError
return self.process()


class FFmpegMP3(FFmpegExporter):
Expand All @@ -162,7 +162,7 @@ def convert(self) -> int:
command.append("-f")
command.append("mp3")
command.append("-")
return self.process()
return super().convert()


class FFmpegOGG(FFmpegExporter):
Expand All @@ -179,7 +179,7 @@ def convert(self) -> int:
command.append("-f")
command.append("ogg")
command.append("-")
return self.process()
return super().convert()


class FFmpegM4A(FFmpegExporter):
Expand All @@ -202,4 +202,4 @@ def convert(self) -> int:
command.append("-f")
command.append("ipod")
command.append(self.filename)
return self.process()
return super().convert()

0 comments on commit 7aebd0a

Please sign in to comment.