Skip to content

[Wip] Youtube App #1086

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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open

[Wip] Youtube App #1086

wants to merge 39 commits into from

Conversation

JonasJesus42
Copy link
Contributor

What is this Contribution About?

Please provide a brief description of the changes or enhancements you are proposing in this pull request.

Issue Link

Please link to the relevant issue that this pull request addresses:

Loom Video

Record a quick screencast describing your changes to help the team understand and review your contribution. This will greatly assist in the review process.

Demonstration Link

Provide a link to a branch or environment where this pull request can be tested and seen in action.

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.67.1 update
  • 🎉 for Minor 0.68.0 update
  • 🚀 for Major 1.0.0 update

…nd loaders, removing unnecessary code and improving project organization
@matheusgr matheusgr changed the title Wip Wip Wip [Wip] Youtube-like API Apr 8, 2025
@matheusgr matheusgr changed the title [Wip] Youtube-like API [Wip] Youtube App Apr 8, 2025
Copy link
Contributor

@matheusgr matheusgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translate to English.

Comment on lines +624 to +631
## Observações

- Para modificar informações do canal, você deve ser o proprietário do canal ou ter permissões adequadas.
- Para pinar comentários, você deve ser o proprietário do vídeo ou ter permissões adequadas.
- Para acessar dados de analytics, você precisa ter o escopo `yt-analytics.readonly` autorizado.
- Algumas operações exigem tokens de acesso com escopos específicos.
- A API do YouTube tem restrições específicas sobre quais partes podem ser atualizadas em conjunto. Por exemplo, `snippet` e `brandingSettings` devem ser atualizados em chamadas separadas.
- Operações como curtir comentários, definir status de moderação e outras ações sem conteúdo devem usar a abordagem de parâmetros na URL, não no corpo da requisição.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put that above the resources.

It seems that most problems that uses may have are relate to this... so, keep it up on the doc.

@@ -0,0 +1,631 @@
# App do YouTube
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English.... :) All the way.

Comment on lines 7777 to 7783
export type GetShopInfoQueryVariables = Exact<{
identifiers: Array<HasMetafieldsIdentifier> | HasMetafieldsIdentifier;
}>;


export type GetShopInfoQuery = { shop: { name: string, description?: string | null, privacyPolicy?: { title: string, body: string } | null, refundPolicy?: { title: string, body: string } | null, shippingPolicy?: { title: string, body: string } | null, subscriptionPolicy?: { title: string, body: string } | null, termsOfService?: { title: string, body: string } | null, metafields: Array<{ description?: string | null, key: string, namespace: string, type: string, value: string, reference?: { image?: { url: any } | null } | {} | null, references?: { edges: Array<{ node: { image?: { url: any } | null } | {} }> } | null } | null> } };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GetShopInfoQueryVariables = Exact<{
identifiers: Array<HasMetafieldsIdentifier> | HasMetafieldsIdentifier;
}>;
export type GetShopInfoQuery = { shop: { name: string, description?: string | null, privacyPolicy?: { title: string, body: string } | null, refundPolicy?: { title: string, body: string } | null, shippingPolicy?: { title: string, body: string } | null, subscriptionPolicy?: { title: string, body: string } | null, termsOfService?: { title: string, body: string } | null, metafields: Array<{ description?: string | null, key: string, namespace: string, type: string, value: string, reference?: { image?: { url: any } | null } | {} | null, references?: { edges: Array<{ node: { image?: { url: any } | null } | {} }> } | null } | null> } };

should be here?

lives/types.ts Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a youtube specific file. not something that is universal.

( https://schema.org/VideoObject is the most related schemaOrg that I could find).

Move to youtube app.

deco.ts Outdated
@@ -10,6 +10,7 @@ const compatibilityApps = [{

const config = {
apps: [
app("Youtube"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid upper case on app names and directories

Comment on lines 113 to 116
/**
* Parse SRT format captions
*/
function parseSrtCaption(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utility functions, I would keep apart from the loader.

try {
// Construir a URL para buscar as categorias de vídeos
const url =
`https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&regionCode=${regionCode}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the google base API address should be something defined on the mod.ts, and reused here and on the other API URLs.

Comment on lines 191 to 208
if (response.status === 401) {
mensagem =
"Token de autenticação inválido ou expirado. Faça login novamente.";
} else if (response.status === 403) {
mensagem =
"Acesso negado. Verifique se você tem permissão para listar transmissões e o escopo 'youtube.livestream' está autorizado.";
} else if (response.status === 404) {
mensagem =
"Recurso não encontrado. Verifique se os IDs das transmissões estão corretos.";
} else if (response.status === 400) {
mensagem = "Solicitação inválida. Verifique os parâmetros enviados.";
} else if (response.status === 500) {
mensagem =
"Erro interno do servidor YouTube. Tente novamente mais tarde.";
} else if (response.status === 429) {
mensagem =
"Limite de requisições excedido. Aguarde um momento e tente novamente.";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is something that you may need to do for every response.

Comment on lines 83 to 86
return {
success: false,
message: `Erro ao avaliar comentário: ${error.message}`,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should create a uniform API.

you can either... all return success with { data: any, error: Error }, which is a more common patter for APIs, or return data if successful, and throw an exception otherwise.

Usually I am more prone to the return data/exception for user facing APIs and data/error pattern for libraries (such as postgres).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This success/message seems confusing, since you are probably defining a UI message to be set by the API. And message means two different things here (error message or successful message if the success is true or false).

return { success: false, message: "Autenticação necessária" };
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try catchs are too big on your functions. create a separate call for that logic, and wrap it inside here.

try {
   trueActionFn(props);
} catch (err) {
   // do something
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why not to use the google-data-api?

…code, as well as update the import structure and improve code readability
…tor the access token management framework, including adding functions for cookie handling
… functionality in various YouTube actions and uploaders
…be API, improving type structure and code readability
…rs to English, improving code consistency and clarity
…o get the access token and channel data, and moving the default authentication URL to constants
…ode and adjusting the return structure of the authentication function
…g new fields and improving handling of YouTube API responses
…ing logic, including error handling and improved response structure
…ubtitle text loader and improving the response structure and configuration options
…Tube channels and videos, improving the efficiency and structure of responses
…regamento de canais e vídeos do YouTube, melhorando a eficiência e a estrutura das respostas
…ing YouTube video comments and categories, improving response structure and code efficiency
…ndling in YouTube API requests, improving response structure and code efficiency
…details interface, improving response structure and authentication logic
…tions, improving error handling, and refining response structure for better performance
…s on YouTube, adding new error interfaces and improving the structure of responses for greater efficiency
…rfaces. Standardize authentication via getAccessToken(req). Refactor and clean up YouTube integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants