Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #1

Merged
merged 15 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: downlaod yt playlists (hosted)
  • Loading branch information
MSOB7YY committed Nov 27, 2023
commit c8f5a3e2a9a808bfce434c01db8fd50499680064
28 changes: 28 additions & 0 deletions lib/core/namida_converter_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,34 @@ extension CacheGetterVideo on VideoOnlyStream {
}
}

extension StreamInfoUtils on StreamInfoItem {
VideoInfo toVideoInfo() {
return VideoInfo(
id: id,
url: url,
name: name,
uploaderName: uploaderName,
uploaderUrl: uploaderUrl,
uploaderAvatarUrl: uploaderAvatarUrl,
date: date,
isDateApproximation: isDateApproximation,
description: null,
duration: duration,
viewCount: viewCount,
likeCount: null,
category: null,
ageLimit: null,
tags: null,
thumbnailUrl: thumbnailUrl,
isUploaderVerified: isUploaderVerified,
textualUploadDate: textualUploadDate,
uploaderSubscriberCount: -1,
privacy: null,
isShortFormContent: isShortFormContent,
);
}
}

extension FAudioTaggerFFMPEGExtractor on FAudioTagger {
Future<(FAudioModel?, Uint8List?)> extractMetadata({
required String trackPath,
Expand Down
2 changes: 2 additions & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ abstract class LanguageKeys {
String get FAILED_EDITS => _getKey('FAILED_EDITS');
String get FAILED => _getKey('FAILED');
String get FAVOURITES => _getKey('FAVOURITES');
String get FETCHING => _getKey('FETCHING');
String get FILE_NAME_WO_EXT => _getKey('FILE_NAME_WO_EXT');
String get FILE_NAME => _getKey('FILE_NAME');
String get FILE => _getKey('FILE');
Expand Down Expand Up @@ -276,6 +277,7 @@ abstract class LanguageKeys {
String get INFO => _getKey('INFO');
String get INSERTED => _getKey('INSERTED');
String get INSTANTLY_APPLIES => _getKey('INSTANTLY_APPLIES');
String get INVERT_SELECTION => _getKey('INVERT_SELECTION');
String get ITEM => _getKey('ITEM');
String get I_READ_AND_AGREE => _getKey('I_READ_AND_AGREE');
String get JUMP_TO_DAY => _getKey('JUMP_TO_DAY');
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/pages/about_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: use_build_context_synchronously, depend_on_referenced_packages, implementation_imports
// ignore_for_file: depend_on_referenced_packages, implementation_imports

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -180,6 +180,7 @@ class AboutPage extends StatelessWidget {
final stringy = await http.get(Uri.parse('https://raw.githubusercontent.com/namidaco/namida/main/CHANGELOG.md'));
isLoading.value = false;
await Future.delayed(Duration.zero); // delay bcz sometimes doesnt show
// ignore: use_build_context_synchronously
showModalBottomSheet(
showDragHandle: true,
useRootNavigator: true,
Expand Down
3 changes: 1 addition & 2 deletions lib/youtube/functions/download_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ Future<void> showDownloadVideoBottomSheet({
onTap: () async {
if (!await requestManageStoragePermission()) return;
requestIgnoreBatteryOptimizations();
// ignore: use_build_context_synchronously
Navigator.pop(context);
if (context.mounted) Navigator.pop(context);
YoutubeController.inst.downloadYoutubeVideos(
useCachedVersionsIfAvailable: true,
autoExtractTitleAndArtist: settings.ytAutoExtractVideoTagsFromInfo.value,
Expand Down
33 changes: 25 additions & 8 deletions lib/youtube/functions/video_download_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class YTDownloadOptionFolderListTile extends StatefulWidget {
final String Function(String value)? subtitle;
final double trailingPadding;
final VisualDensity? visualDensity;
final double? maxTrailingWidth;

const YTDownloadOptionFolderListTile({
super.key,
Expand All @@ -223,6 +224,7 @@ class YTDownloadOptionFolderListTile extends StatefulWidget {
this.subtitle,
this.trailingPadding = 0,
this.visualDensity,
this.maxTrailingWidth,
});

@override
Expand All @@ -235,6 +237,7 @@ class _YTDownloadOptionFolderListTileState extends State<YTDownloadOptionFolderL

@override
void initState() {
availableDirectoriesNames[widget.initialFolder] = 0; // to put at first
availableDirectoriesNames[''] = 0; // to put at first
int rootFiles = 0;
for (final d in Directory(AppDirs.YOUTUBE_DOWNLOADS).listSync()) {
Expand Down Expand Up @@ -315,7 +318,7 @@ class _YTDownloadOptionFolderListTileState extends State<YTDownloadOptionFolderL
visualDensity: widget.visualDensity,
title: lang.FOLDER,
subtitle: widget.subtitle?.call(groupName.value),
trailingRaw: NamidaPopupWrapper(
trailing: NamidaPopupWrapper(
childrenDefault: [
NamidaPopupItem(
icon: Broken.add,
Expand All @@ -325,9 +328,13 @@ class _YTDownloadOptionFolderListTileState extends State<YTDownloadOptionFolderL
...availableDirectoriesNames.keys.map(
(name) {
final title = name == '' ? lang.DEFAULT : name;
final icon = name == '' ? Broken.folder_2 : Broken.folder;
final icon = name == widget.initialFolder
? Broken.music_playlist
: name == ''
? Broken.folder_2
: Broken.folder;
final count = availableDirectoriesNames[name];
final countText = count == null ? '' : " ($count)";
final countText = count == null || count == 0 ? '' : " ($count)";
return NamidaPopupItem(
icon: icon,
title: "$title$countText",
Expand All @@ -340,15 +347,25 @@ class _YTDownloadOptionFolderListTileState extends State<YTDownloadOptionFolderL
() {
final title = groupName.value == '' ? lang.DEFAULT : groupName.value;
final count = availableDirectoriesNames[groupName.value];
final countText = count == null ? '' : " ($count)";
final countText = count == null || count == 0 ? '' : " ($count)";
return Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Icon(groupName.value == '' ? Broken.folder_2 : Broken.folder, size: 18.0),
Icon(
groupName.value == widget.initialFolder
? Broken.music_playlist
: groupName.value == ''
? Broken.folder_2
: Broken.folder,
size: 18.0),
const SizedBox(width: 6.0),
Text(
"$title$countText",
style: context.textTheme.displayMedium,
ConstrainedBox(
constraints: BoxConstraints(minWidth: 0, maxWidth: widget.maxTrailingWidth ?? context.width * 0.34),
child: Text(
"$title$countText",
style: context.textTheme.displayMedium,
),
),
SizedBox(width: widget.trailingPadding),
],
Expand Down
3 changes: 1 addition & 2 deletions lib/youtube/functions/yt_playlist_utils.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: use_build_context_synchronously

import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand Down Expand Up @@ -46,6 +44,7 @@ extension YoutubePlaylistShare on YoutubePlaylist {
focusNode.requestFocus();

await Future.delayed(Duration.zero); // delay bcz sometimes doesnt show
// ignore: use_build_context_synchronously
await showModalBottomSheet(
context: context,
useRootNavigator: true,
Expand Down
Loading