fix: URL item duration unit in seconds, bad skip button in floating player
This commit is contained in:
parent
0b7d0b8465
commit
1d97fe654e
17
database.py
17
database.py
@ -194,7 +194,7 @@ class Condition:
|
|||||||
|
|
||||||
|
|
||||||
SETTING_DB_VERSION = 2
|
SETTING_DB_VERSION = 2
|
||||||
MUSIC_DB_VERSION = 3
|
MUSIC_DB_VERSION = 4
|
||||||
|
|
||||||
|
|
||||||
class SettingsDatabase:
|
class SettingsDatabase:
|
||||||
@ -504,7 +504,10 @@ class DatabaseMigration:
|
|||||||
1: self.settings_table_migrate_from_1_to_2}
|
1: self.settings_table_migrate_from_1_to_2}
|
||||||
self.music_table_migrate_func = {0: self.music_table_migrate_from_0_to_1,
|
self.music_table_migrate_func = {0: self.music_table_migrate_from_0_to_1,
|
||||||
1: self.music_table_migrate_from_1_to_2,
|
1: self.music_table_migrate_from_1_to_2,
|
||||||
2: self.music_table_migrate_from_2_to_3}
|
2: self.music_table_migrate_from_2_to_4,
|
||||||
|
3: self.music_table_migrate_from_2_to_4
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
self.settings_database_migrate()
|
self.settings_database_migrate()
|
||||||
@ -565,7 +568,7 @@ class DatabaseMigration:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
log.info(f"database: no music table found. Creating music table version {MUSIC_DB_VERSION}.")
|
log.info(f"database: no music table found. Creating music table version {MUSIC_DB_VERSION}.")
|
||||||
self.create_music_table_version_3(conn)
|
self.create_music_table_version_4(conn)
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
@ -608,7 +611,7 @@ class DatabaseMigration:
|
|||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def create_music_table_version_3(self, conn):
|
def create_music_table_version_4(self, conn):
|
||||||
self.create_music_table_version_1(conn)
|
self.create_music_table_version_1(conn)
|
||||||
|
|
||||||
def settings_table_migrate_from_0_to_1(self, conn):
|
def settings_table_migrate_from_0_to_1(self, conn):
|
||||||
@ -671,13 +674,15 @@ class DatabaseMigration:
|
|||||||
|
|
||||||
return 2 # return new version number
|
return 2 # return new version number
|
||||||
|
|
||||||
def music_table_migrate_from_2_to_3(self, conn):
|
def music_table_migrate_from_2_to_4(self, conn):
|
||||||
items_to_update = self.music_db.query_music(Condition(), conn)
|
items_to_update = self.music_db.query_music(Condition(), conn)
|
||||||
for item in items_to_update:
|
for item in items_to_update:
|
||||||
if 'duration' not in item:
|
if 'duration' not in item:
|
||||||
item['duration'] = 0
|
item['duration'] = 0
|
||||||
|
if item['type'] == 'url' or item['type'] == "url_from_playlist":
|
||||||
|
item['duration'] = item['duration'] * 60
|
||||||
|
|
||||||
self.music_db.insert_music(item)
|
self.music_db.insert_music(item)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
return 3 # return new version number
|
return 4 # return new version number
|
||||||
|
@ -95,10 +95,10 @@ class URLItem(BaseItem):
|
|||||||
if not info:
|
if not info:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.duration > var.config.getint('bot', 'max_track_duration') != 0:
|
if self.duration > var.config.getint('bot', 'max_track_duration') * 60 != 0:
|
||||||
# Check the length, useful in case of playlist, it wasn't checked before)
|
# Check the length, useful in case of playlist, it wasn't checked before)
|
||||||
log.info(
|
log.info(
|
||||||
"url: " + self.url + " has a duration of " + str(self.duration) + " min -- too long")
|
"url: " + self.url + " has a duration of " + str(self.duration / 60) + " min -- too long")
|
||||||
raise ValidationFailedError(constants.strings('too_long', song=self.title))
|
raise ValidationFailedError(constants.strings('too_long', song=self.title))
|
||||||
else:
|
else:
|
||||||
self.ready = "validated"
|
self.ready = "validated"
|
||||||
@ -125,14 +125,14 @@ class URLItem(BaseItem):
|
|||||||
for i in range(attempts):
|
for i in range(attempts):
|
||||||
try:
|
try:
|
||||||
info = ydl.extract_info(self.url, download=False)
|
info = ydl.extract_info(self.url, download=False)
|
||||||
self.duration = info['duration'] / 60
|
self.duration = info['duration']
|
||||||
self.title = info['title']
|
self.title = info['title']
|
||||||
self.keywords = info['title']
|
self.keywords = info['title']
|
||||||
succeed = True
|
succeed = True
|
||||||
return True
|
return True
|
||||||
except youtube_dl.utils.DownloadError:
|
except youtube_dl.utils.DownloadError:
|
||||||
pass
|
pass
|
||||||
except KeyError: # info has no 'duration'
|
except KeyError: # info has no 'duration'
|
||||||
break
|
break
|
||||||
|
|
||||||
if not succeed:
|
if not succeed:
|
||||||
|
@ -759,6 +759,7 @@ let volume_popover_instance = null;
|
|||||||
let volume_popover_show = false;
|
let volume_popover_show = false;
|
||||||
|
|
||||||
volume_popover_btn.addEventListener('click', function(e){ e.stopPropagation(); })
|
volume_popover_btn.addEventListener('click', function(e){ e.stopPropagation(); })
|
||||||
|
volume_popover_div.addEventListener('click', function(e){ e.stopPropagation(); })
|
||||||
|
|
||||||
function toggleVolumePopover(){
|
function toggleVolumePopover(){
|
||||||
if (!volume_popover_show){
|
if (!volume_popover_show){
|
||||||
|
@ -440,7 +440,8 @@
|
|||||||
onclick="request('post', {action: 'pause'})">
|
onclick="request('post', {action: 'pause'})">
|
||||||
<i class="fas fa-pause"></i>
|
<i class="fas fa-pause"></i>
|
||||||
</button>
|
</button>
|
||||||
<button id="playerSkipBtn" class="btn btn-primary btn-sm">
|
<button id="playerSkipBtn" class="btn btn-primary btn-sm"
|
||||||
|
onclick="request('post', {action : 'next'})">
|
||||||
<i class="fas fa-fast-forward"></i>
|
<i class="fas fa-fast-forward"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user