[Docs] add docs for youtube channel (#1072)
Co-authored-by: Deven Patel <deven298@yahoo.com>
This commit is contained in:
@@ -8,6 +8,7 @@ Embedchain comes with built-in support for various data sources. We handle the c
|
|||||||
<Card title="📰 PDF file" href="/components/data-sources/pdf-file"></Card>
|
<Card title="📰 PDF file" href="/components/data-sources/pdf-file"></Card>
|
||||||
<Card title="📊 CSV file" href="/components/data-sources/csv"></Card>
|
<Card title="📊 CSV file" href="/components/data-sources/csv"></Card>
|
||||||
<Card title="📃 JSON file" href="/components/data-sources/json"></Card>
|
<Card title="📃 JSON file" href="/components/data-sources/json"></Card>
|
||||||
|
<Card title="📽️ Youtube Channel" href="/components/data-sources/youtube-channel"></Card>
|
||||||
<Card title="📺 Youtube" href="/components/data-sources/youtube-video"></Card>
|
<Card title="📺 Youtube" href="/components/data-sources/youtube-video"></Card>
|
||||||
<Card title="📝 Text" href="/components/data-sources/text"></Card>
|
<Card title="📝 Text" href="/components/data-sources/text"></Card>
|
||||||
<Card title="📚 Documentation website" href="/components/data-sources/docs-site"></Card>
|
<Card title="📚 Documentation website" href="/components/data-sources/docs-site"></Card>
|
||||||
|
|||||||
20
docs/components/data-sources/youtube-channel.mdx
Normal file
20
docs/components/data-sources/youtube-channel.mdx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: '📽️ Youtube Channel'
|
||||||
|
---
|
||||||
|
|
||||||
|
To add all the videos from a youtube channel to your app, use the data_type as `youtube_channel`.
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Make sure you have all the required packages installed before using this data type. You can install them by running the following command in your terminal.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -u "embedchain[youtube]"
|
||||||
|
```
|
||||||
|
</Note>
|
||||||
|
|
||||||
|
```python
|
||||||
|
from embedchain import Pipeline as App
|
||||||
|
|
||||||
|
app = App()
|
||||||
|
app.add("@channel_name", data_type="youtube_channel")
|
||||||
|
```
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
title: '📺 Youtube'
|
title: '📺 Youtube'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
To add any youtube video to your app, use the data_type as `youtube_video`. Eg:
|
||||||
To add any youtube video to your app, use the data_type (first argument to `.add()` method) as `youtube_video`. Eg:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from embedchain import Pipeline as App
|
from embedchain import Pipeline as App
|
||||||
|
|||||||
@@ -189,8 +189,7 @@ class EmbedChain(JSONSerializable):
|
|||||||
data_type = detect_datatype(source)
|
data_type = detect_datatype(source)
|
||||||
|
|
||||||
# `source_hash` is the md5 hash of the source argument
|
# `source_hash` is the md5 hash of the source argument
|
||||||
hash_object = hashlib.md5(str(source).encode("utf-8"))
|
source_hash = hashlib.md5(str(source).encode("utf-8")).hexdigest()
|
||||||
source_hash = hash_object.hexdigest()
|
|
||||||
|
|
||||||
self.user_asks.append([source, data_type.value, metadata])
|
self.user_asks.append([source, data_type.value, metadata])
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class DirectoryLoader(BaseLoader):
|
|||||||
if not directory_path.is_dir():
|
if not directory_path.is_dir():
|
||||||
raise ValueError(f"Invalid path: {path}")
|
raise ValueError(f"Invalid path: {path}")
|
||||||
|
|
||||||
|
logging.info(f"Loading data from directory: {path}")
|
||||||
data_list = self._process_directory(directory_path)
|
data_list = self._process_directory(directory_path)
|
||||||
doc_id = hashlib.sha256((str(data_list) + str(directory_path)).encode()).hexdigest()
|
doc_id = hashlib.sha256((str(data_list) + str(directory_path)).encode()).hexdigest()
|
||||||
|
|
||||||
@@ -44,6 +45,8 @@ class DirectoryLoader(BaseLoader):
|
|||||||
if file_path.is_file() and (not self.extensions or any(file_path.suffix == ext for ext in self.extensions)):
|
if file_path.is_file() and (not self.extensions or any(file_path.suffix == ext for ext in self.extensions)):
|
||||||
loader = self._predict_loader(file_path)
|
loader = self._predict_loader(file_path)
|
||||||
data_list.extend(loader.load_data(str(file_path))["data"])
|
data_list.extend(loader.load_data(str(file_path))["data"])
|
||||||
|
elif file_path.is_dir():
|
||||||
|
logging.info(f"Loading data from directory: {file_path}")
|
||||||
return data_list
|
return data_list
|
||||||
|
|
||||||
def _predict_loader(self, file_path: Path) -> BaseLoader:
|
def _predict_loader(self, file_path: Path) -> BaseLoader:
|
||||||
|
|||||||
@@ -358,10 +358,6 @@ def is_valid_json_string(source: str):
|
|||||||
_ = json.loads(source)
|
_ = json.loads(source)
|
||||||
return True
|
return True
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logging.error(
|
|
||||||
"Insert valid string format of JSON. \
|
|
||||||
Check the docs to see the supported formats - `https://docs.embedchain.ai/data-sources/json`"
|
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user